var JSONObject = {
stringProp: 'stringProp',
booleanProp: false,
intProp: 8
}
var JSONString = JSON.stringify(JSONObject);
console.log(JSONString);
/* output
* {"stringProp":"stringProp","booleanProp":false,"intProp":8}
*/
var JSONObject = {
stringProp: 'stringProp',
booleanProp: false,
intProp: 8
}
var JSONString = JSON.stringify(JSONObject, ['intProp']);
console.log(JSONString);
/* output
* {"intProp":8}
*/
var JSONObject = {
stringProp: 'stringProp',
booleanProp: false,
intProp: 8
}
var JSONString = JSON.stringify(JSONObject, null, 2);
console.log(JSONString);
/* output:
* {
* "stringProp": "stringProp",
* "booleanProp": false,
* "intProp": 8
* }
*/