My question is sort of stupid that why

JSON.stringify({"annotation": [{"x":1, "y":2}, {"x":1, "y":2}]})

does not return

{"annotation": [{"x": 1, "y": 2}, {"x": 1, "y": 2}]}

but returns

{"annotation":"[{\"x\": 1, \"y\": 2}, {\"x\": 1, \"y\": 2}]"}

and how can I get the first output?

share|improve this question
1  
In which browser are you having this behavior?. If it's a browser with no native JSON support, which library are you using? – CMS Oct 18 '10 at 20:52
I'm using the widely used library from, json.org/json2.js. This seems to be Prototype's conflict. – Zifei Tong Oct 18 '10 at 21:03
feedback

1 Answer

up vote 2 down vote accepted

Are you using Prototype? This question may be related:

http://stackoverflow.com/questions/710586/json-stringify-bizarreness

share|improve this answer
Thanks, problem solved :) – Zifei Tong Oct 18 '10 at 21:04
I have had this problem without using Prototype. – psycho brm Nov 24 '12 at 0:31
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.