Possible Duplicate:
JSON.stringify() bizarreness
OK, so I use the various JSON methods (stringify and parse) but have recently run across a page where they don't behave correctly. I am using Chrome version 23.0.1271.91 m
As an example, if I throw the following in to the console:
var x = [{"color":"red"},{"name":"ryan"}];
console.log('original object = ', x);
var y = JSON.stringify(x);
console.log('stringified = ', y);
var w = JSON.parse(y);
console.log('parsed = ', w);
I usually get back this:
original object = [Object, Object]
stringified = [{"color":"red"},{"name":"ryan"}]
parsed = [Object, Object]
But on one page in particular I get the following instead:
original object = [Object, Object]
stringified = "[{\"color\": \"red\"}, {\"name\": \"ryan\"}]"
parsed = [{"color": "red"}, {"name": "ryan"}]
Where parsed is a string with the value of [{"color": "red"}, {"name": "ryan"}] rather than an object with those values/properties.
I'm just not really sure how to go about solving this issue. Obviously, something is going wrong in the serialization. This is in an environment where I don't have a lot of control over what other scripts are running (it's a plugin) so the solution can't really involve disabling other scripts which might be causing interference because I may not know about them and that may cause additional problems.