Learn JSON in 5 Minutes

Published by on January 2 2021

This article was adapted from Ajay Yadav's article on Dev.to, found here: https://dev.to/ajayyadavexpo/learn-json-in-5-minutes-8ee

JSON Stands for JavaScript Object Notation, It is lightweight format for storing and transporting data through API from server to a web page. It is also 'self describing' and easy to understand. Here's an example:



data.json
parse.jsx

Continue scrolling

JSON Strings

Here "name" is a key and "Ajay" is its value

JSON Numbers

Here "Age" is a key and 34 is value, which is a number type.

JSON Objects

Here "friends" is a key and its values are in array data type which contains two objects. His first friend is Shyam and second friend is Rahul.

JSON Arrays

Here "hobbies" is a key and it has multiple values in array format separated by commas.

JSON Booleans

Here "isFriend" is a key and its value in Boolean format which can be either true or false.

JSON Null

"middlename" is a key and its value in null format. If something has no value than we can assign null to its value. For example, some people have no middle name in that case we can assign null value.

JSON.parse()

A common use of JSON is to exchange data to/from a web server. When receiving data from a web server, the data is always in sting format.

Parse the data with JSON.parse() and the data becomes a JavaScript object.