K
Keith Hughitt
Hi all,
I've been testing out the native JSON support in Firefox 3.5, and have
run into some issues. I was wondering if someone might be able to help
me figure out what is going on.
I would like to be able to encode and decode an array of JavaScript
object literals, however, the parser doesn't seem to like having an
array as the outermost container, e.g.:
// Okay
JSON.parse(JSON.stringify({name: "bob",id: 3}));
// Okay
JSON.parse(JSON.stringify({objects: ["bob", 3]}));
// Not Okay
JSON.parse(JSON.stringify([{name: "bob",id: 3}, {name: "john",id:
4}]));
// Doesn't work, either
JSON.parse(JSON.stringify([1,2,3]));
All of the above should be valid JSON. So why doesn't the above work?
Any feedback would be greatly appreciated.
Thanks!
Keith
I've been testing out the native JSON support in Firefox 3.5, and have
run into some issues. I was wondering if someone might be able to help
me figure out what is going on.
I would like to be able to encode and decode an array of JavaScript
object literals, however, the parser doesn't seem to like having an
array as the outermost container, e.g.:
// Okay
JSON.parse(JSON.stringify({name: "bob",id: 3}));
// Okay
JSON.parse(JSON.stringify({objects: ["bob", 3]}));
// Not Okay
JSON.parse(JSON.stringify([{name: "bob",id: 3}, {name: "john",id:
4}]));
// Doesn't work, either
JSON.parse(JSON.stringify([1,2,3]));
All of the above should be valid JSON. So why doesn't the above work?
Any feedback would be greatly appreciated.
Thanks!
Keith