Convert array to JSON
How about
var jsonString = JSON.stringify(myArray);
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.