Serialize javascript object to json and back
问题 I am using to a jQuery post method to send some data to a server. Rather than constructing the JSON string myself, I would like to simply use a Javascript object. When I get the return string (in JSON) I would like to automatically construct a corresponding javascript object. Is this possible? Thanks in advance. 回答1: Checkout JSON.stringify() and JSON.parse() in JSON2 documentation Example: myData = JSON.parse(text); // from json string to js object var myJSONText = JSON.stringify(myObject,