JSON
As you have been using JavaScript up until now in this book, you should feel right at home with the syntax of JSON, as it is derived from JavaScript and closely resembles object structures you have already learned in previous chapters. JSON, usually pronounced like the name Jason, is lightweight, easy for humans to read and write, and easy for machines to parse and work with.
There are two main data structures used in JSON:
- A collection of key-value pairs enclosed in curly-braces
{ }
- A list of values enclosed in square brackets
[ ]
Here's a sample JSON object that shows different structures and value types:
sample_json.json
1Â { 2Â Â Â Â Â "twitter_username": "@LeoDiCaprio", 3Â Â Â Â Â "first_name": "Leonardo", 4Â Â Â Â Â "last_name": "DiCaprio", 5Â Â Â Â Â "famous_movies": [{ 6Â Â Â ...