Creates JSON string from a JavaScript object
var obj = { name: "John", age: 30, city: "New York" };

// Converts object into JSON string
var myJSON = JSON.stringify(obj);

// Puts the string into element with id: demo
document.getElementById("demo").innerHTML = myJSON;
by Valeri Tandilashvili
4 years ago
JSON
JavaScript
JS JSON
1
Pro tip: use ```triple backticks around text``` to write in code fences