β JSON stands Type JavaScript Object Notation(JSON), JSON is Textual content Primarily based Information Format, that’s used to retailer and switch information,
it’s often helpful to despatched to information server to webpage,
Syntax of JSON
{
"MoviesStar":[
{"firstName":"John","lastName": "cena"},
{"firstName":"linda","lastName": "Friday"},
{"firstName":"Teresa","lastName": "Plamer"},
]
}
π΄This above JSON Syntax defines film star title object: an array of three moviestar file
βIn JSON information saved in KEY/VALUE Pair separate by comma,
β¨JSON DATA
JSON information is written as title/worth pairs, identical to JavaScript object Properties, A reputation and worth pair consists of area title(in double qoutes), adopted by a colon, adopted by worth,
e.g “title”: “Tony”
JSON Objects
The JSON object is written inside curly braces{}, JSON objects can comprise a number of key/worth pairs,
for e.g :-
{
"firstName":"Tony",
"lastName": "stark"
}
JOSN Arrays:
JSON array is written inside sq. Brackets[].
for e.g:-
//JSON array
["audi", "BMW", "jaguar"]
//JSON Array containing objects
[
{"name": "Tony", "age": 48},
{"name": "Peter", "age": 20}
]
π«Observe:
JSON information can comprise objects and arrays. Nevertheless, not like Javascript objects, JSON information connot comprise features as worth.
βAccessing JSON information
We are able to entry JSON information utilizing the dot notation LIKE this,
//JSON object
const information = {
"title": "john",
"age": 22,
"passion": {
"studying": true,
"gamming" false,
"sport": "soccer"
},
"class":["JavaScript", "HTML", "CSS"]
//accessing JSON object
console.log(information.title); //john
console.log(information.passion); //{"studying": true,"gamming" false,"sport": "soccer"}
console.log(information.passion.sport); //soccer
console.log(information.class[1]); //HTML
}