how to format a stringified json object ?
JSON.stringify({a: 'avalue', b: 'bvalue'});
To output this :
{
a: 'valuea',
b: 'valueb'
}
instead of this :
{a:'valuea', b: 'valueb'}
how to format a stringified json object ?
JSON.stringify({a: 'avalue', b: 'bvalue'});
To output this :
{
a: 'valuea',
b: 'valueb'
}
instead of this :
{a:'valuea', b: 'valueb'}
JSON.stringify
function takes 3 parameters. The third one defines how many spaces will be inserted for indentation. So that you can use it:
JSON.stringify({a: 'avalue', b: 'bvalue'}, null, 2);