Friday, March 23, 2012

Serializing to JSON in jQuery

JSON-js - JSON in JavaScript.
To convert an object to JSON, use JSON.stringify:
var json_text = JSON.stringify(your_object, null, 2);
To convert a JSON string to a JS object, use JSON.parse:
var your_object = JSON.parse(json_text);

It was recently recommended by John Resig:

No comments:

Post a Comment