1var obj = {a: "a", b: "b" /*...*/};
2var string = JSON.stringify(obj);
3// OUTPUT:
4// "{'a':'a', 'b':'b'}"
1const myObj = {
2 name: 'Skip',
3 age: 2,
4 favoriteFood: 'Steak'
5};
6
7const myObjStr = JSON.stringify(myObj);
8
9console.log(myObjStr);
10// "{"name":"Skip","age":2,"favoriteFood":"Steak"}"
11
12console.log(JSON.parse(myObjStr));
13// Object {name:"Skip",age:2,favoriteFood:"Steak"}