rhgiant — 2012-03-19T08:00:41-04:00 — #1
I'm having a PHP array which I json_encode. This array is used by a .js file.
Here's how I do so far:
var myResult = JSON.parse(arrayJsonEncoded);
myResultArray = myResult.split(",");
//would expect result2 but... nothing
How do you retrieve an array from a json string?
paul_wilkins — 2012-03-19T19:08:40-04:00 — #2
Head along to json.org and at the end of the page you will see code libraries for a large number of languages.
felgall — 2012-03-20T16:28:49-04:00 — #3
And if you don't need to support IE7 and earlier then you can just use the JSON.stringify and JSON.parse methods without needing that script to define them as all modern browsers now have that JSON object built in (which is why that script first checks whether or not the JSON object exists - so that it can avoid overwriting the built in object that most browsers now have that provides the same functionality).