jQuery.toJSON()
Categories: Utilities
jQuery.toJSON( obj )Returns: string
Plugin: jQuery.json
Description: Takes a JavaScript object and returns the resulting well-formed JSON string.
-
jQuery.toJSON( obj )
version added: 1.0obj A object to stringify.
Stringify a JavaScript object and returns the resulting well-formed JSON string.
-
Stringify an object.
Code:
$.toJSON({ banana: "yellow", strawberry: "red", group: { red: "strawberry", blue: [ "berry", "other", "[]" ] } });
Results:
{"banana":"yellow","strawberry":"red","group":{"red":"strawberry","blue":["berry","other","[]"]}}