1var obj = {name: "Martin", age: 30, country: "United States"};
2
3// Converting JS object to JSON string
4var json = JSON.stringify(obj);
5
6console.log(json);
7// Prints: {"name":"Martin","age":30,"country":"United States"}
8"https://www.tutorialrepublic.com/faq/how-to-convert-js-object-to-json-string.php"
1var person={"first_name":"Tony","last_name":"Hawk","age":31};
2var personJSONString=JSON.stringify(person);
1var jsonPerson = '{"first_name":"billy", "age":23}';
2var personObject = JSON.parse(jsonPerson); //parse json string into JS object
1
2
3 var obj = { name: "John", age: 30, city: "New York" };
4var myJSON =
5 JSON.stringify(obj);
6document.getElementById("demo").innerHTML = myJSON;