json stringify how to format code example
Example 1: JSON.stringify pretty
var str = JSON.stringify(obj, null, 2); // spacing level = 2
Example 2: Javascript object to JSON string
var person={"first_name":"Tony","last_name":"Hawk","age":31};
var personJSONString=JSON.stringify(person);