Convert Array to Json

103,431

Solution 1

In modern browsers you can simply use JSON.stringify(someJSObject) to convert any JavaScript object (that includes arrays) to a JSON string.

To ensure it also works in less modern browsers, include https://github.com/douglascrockford/JSON-js/blob/master/json2.js on your page.

Solution 2

How about

var jsonString = JSON.stringify(myArray);
Share:
103,431
sachin
Author by

sachin

-(id) init{ self = [ios init] + [flex init] + [cakephp init]; return self; }

Updated on July 09, 2022

Comments