Sunday, October 23, 2022
HomeWordPress DevelopmentWhat's JavaScript JSONπŸ“– - DEV Neighborhood πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

What’s JavaScript JSONπŸ“– – DEV Neighborhood πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»


βœ” 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"},
]
}
Enter fullscreen mode

Exit fullscreen mode

πŸ”΄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"
}
Enter fullscreen mode

Exit fullscreen mode

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}
]
Enter fullscreen mode

Exit fullscreen mode

🚫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
}
Enter fullscreen mode

Exit fullscreen mode

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments