Is it possible convert string from JSON.stringify back to Array?
1 Answer
JSON.parse is your friend and answer :)
//examples:
JSON.parse('{}'); // {}
JSON.parse('true'); // true
JSON.parse('"foo"'); // "foo"
JSON.parse('[1, 5, "false"]'); // [1, 5, "false"]
JSON.parse('null'); // null
5 Comments
Ricardo Souza
Beware of browser compatibility issues, as noted on this link: developer.mozilla.org/en-US/docs/JavaScript/Reference/….
Dory Zidon
dude it's talking about ff 3.5, that's like history :) all browsers today support JSON...
Ricardo Souza
Yep, I know, but IE8- still haunts the web...
Dory Zidon
it's supported in IE8..caniuse.com/json
Ricardo Souza
Well... It all dependes on the target audience, but I think it's always better to use a polyfill like json2 in case the browser does not support the native APIs.