Skip to Content Learn & Share

Serializing to JSON in jQuery

Be First!
by March 23, 2012 JAVASCRIPT, JSON
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:



Leave a Reply