I am using JSOn in my javascript code. the javascript gets the following JSON message:
{"param1":1, "param2":{"aaa":1,"bbb":2,"ccc":3}, "param3":true}
In JavaScript I wrote the following code:
parsedArgs = JSON.parse(args);
alert(parsedArgs.param2);
parsedArgs.param2= JSON.parse(parsedArgs.param2);
in the alert I can see [Object object] but JSON.parse(parsedArgs.param2) fails with SyntaxError: invalidcharacter.
I want to get the inner parameters of param2 but JSON parser is not working. can you please help me? what is my problem?
thanks
JSON.parse()expects a JSON string, not an arbitrary JavaScript variable. See LightStyle's answer.alert(parsedArgs.param2.aaa);and check the result