Things to remember...
JSON stands for JavaScript Object Notation.
JSON is very lightweight as compared to XML.
It is text format for storing and retrieving data.
It is human readable and easy to understand.
It is very good to use JSON rather than XML.
With JSON, can easily integrate with JavaScript.
The file type for JSON files is ".json"
example of JSON...
'{"name":"Tae", "age":26, "bike":null, "isGood" : true}'
in the above example, we can see that JSON is like an object that has key-value pairs. you have to enclose the JSON object with backticks(``).
It can take values as numbers, strings, null, Boolean, array and object.
You can also store an array in array, object in arrays as long as it is readable.
``
newJson = '{"name":"Tae", "age":26, "bike":null, "isGood" : true}'
//'{"name":"Tae", "age":26, "bike":null, "isGood" : true}'
parsedJson = JSON.parse(newJson)
// {name: 'Tae', age: 26, bike: null, isGood: true}
parsedJson['age']
//26
parsedJson["isGood"]
//true
``
Store json object in new variable named newJson.
parse the jSON object so that you will get the JavaScript object and can access JavaScript object.
Top comments (1)