07-22-2019 04:17
07-22-2019 04:17
var test = JSON.parse('{ "name":"John", "age":30, "city":"New York"}');
console.log('testing parsing', test);
i have used this sample josn to parse but i am unable to parse.
Can anyone help me to get it right.
Thanks in advance
07-22-2019 06:32
07-22-2019 06:32
What is the error?
07-22-2019 06:40
07-22-2019 06:40
I get [object] [object] when i parse the response
07-22-2019 06:44
07-22-2019 06:44
thats because it is an object. you need to specify what exactly you want to see.
try
console.log('testing parsing', test.name);
07-22-2019 13:52
07-22-2019 13:52
...or you could try console.log(JSON.stringify(test)) if you don't mind going around in a circle. 🙂
I'm also not convinced that " are beneficial around object attribute names; eg, for "name".
07-23-2019 05:12
07-23-2019 05:12
Thank you so much for your input.
As you said that is object.