JSON OBJECT
JSON.parse() :-
JavaScript has a built in function for converting JSON strings into JavaScript objects.
let myJSON = '{"name" :"jay","age":30,"email":"jay@gmail.com"}';
let obj = JSON.parse(text)
document.wright(obj.name); // outpot:- jay
document.wright(obj); // outpot:- [object Object]
JSON.stringify() :-
JavaScript also has a built in function for converting an object into a JSON string.
let obj = {name: "John", age: 30, city: "New York"};
let myJSON = JSON.stringify(obj);
document.wright(myJSON);
// output :- {name: "John", age: 30, city: "New York"}
JSON OBJECT :- {"fname":"John" , "lname":"John"} // fileName.json
JS OBJECT :- let obj = {fname:"John" ,lname :'Chouhan'}
// call :- obj.name or obj["name"]
JSON Values :-
values must be one of the following data types:
• a string
• a number
• an object
• an array
• a boolean
• null
JavaScript object values :-
values must be one of the following data types:
• a string
• a number
• an object
• an array
• a boolean
• null
• a function
• a date
• undefined
JSON Files
File type for JSON files is ".json"
MIME type for JSON text is "application/json"