Here I\'m creating a JavaScript object and converting it to a JSON string, but JSON.stringify returns \"[object Object]\" in this case, instead of
JSON.stringify
\"[object Object]\"
JSON.stringify returns "[object Object]" in this case
That is because you are calling toString() on the object before serializing it:
toString()
JSON.stringify(theObject.toString()) /* <-- here */
Remove the toString() call and it should work fine:
alert( JSON.stringify( theObject ) );