Table of Contents
JSON rules
- To access JSON data that is parsed as a JS object into a variable in JavaScript, we use dot/bracket notation as shown below.
- To drill down further, we need to chain the required property name with the required index of the array together. This is explained below:
Note: All codes are written directly into the console of a browser so that, instantly an error can be identified. - It is mandatory to use double quotes [single quotes are not valid] around strings and property names in JSON.
- Even a single comma can cause a JSON file to go wrong. Therefore, it is very important to use a JSON validator, before passing JSON to our code. A JSON validator like jsonlint.com, helps us to identify errors within our JSON code.
0 Comments