The
JSON.stringify() method does the convertion of a JavaScript object into a JSON-formatted string.
JSON.stringify() is a function filters and transform the way a value is stringified EXAMPLE: var scores = { "Dhoni": 70, "Dhavan": 80, "Ashwin": 30 };
var passed = JSON.stringify(scores, function (key, value) {
if (value < 40) {
return undefined;
} else {
return value;
}
});
alert(passed); // {"Dhoni":70,"Dhavan":80}