All technological notes.
JSON
JavaScript Object NotationJSON is often used when data is sent from a server to a web page.
Syntax Rules
name/value pairsJSON.parse(): JSON string to JS objectlet json_str =
'{ "employees" : [' +
'{ "firstName":"John" , "lastName":"Doe" },' +
'{ "firstName":"Anna" , "lastName":"Smith" },' +
'{ "firstName":"Peter" , "lastName":"Jones" } ]}';
const json_obj = JSON.parse(json_str);
console.log(json_obj);
// {
// employees: [
// { firstName: 'John', lastName: 'Doe' },
// { firstName: 'Anna', lastName: 'Smith' },
// { firstName: 'Peter', lastName: 'Jones' }
// ]
// }
console.log(typeof json_obj); //object
JSON.stringify(): JS object into stringconst obj = { name: "John", age: 30, city: "New York" };
const json_str = JSON.stringify(obj);
console.log(json_str); //{"name":"John","age":30,"city":"New York"}
console.log(typeof json_str); //string