Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
118
rated 0 times [  121] [ 3]  / answers: 1 / hits: 37450  / 13 Years ago, wed, february 15, 2012, 12:00:00

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?


More From » jquery

 Answers
68

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, replacer); // js object to json string

[#87447] Tuesday, February 14, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jackie

Total Points: 442
Total Questions: 107
Total Answers: 94

Location: Honduras
Member since Sun, Dec 26, 2021
2 Years ago
jackie questions
Sat, Sep 18, 21, 00:00, 3 Years ago
Wed, Jul 14, 21, 00:00, 3 Years ago
;