How do we convert a string in JSON format into objects?`
JSON.parse();
var json = '{"result":true, "count":42}';
obj = JSON.parse(json);console.log(obj.count); // expected output: 42
How do we convert a object or value into a JSON string?
JSON.stringify()
examples
console.log(JSON.stringify({ x: 5, y: 6 }));
// expected output: "{"x":5,"y":6}"console.log(JSON.stringify([new Number(3), new String('false'), new Boolean(false)]));
// expected output: "[3,"false",false]"What is Json
Basically a javascript object format in string form
Stands for javascript object notation. It is a text format that makes it easy to share data between devices like client and servers.
It is language independent and is an alternative to XML.
It is extremely easy to parse the text information into a javascript object.