What Is JSON? Explained With JSON Examples

Jul 3, 2018

2 mins read

Published in

What is JSON?

What is JSON? JSON is a way to store, persist data in a structure which is easy to read and easy to access. JSON stands for JavaScript Object Notation, which machine can understand and generate. JSON structure provides a human-readable collection of information to explain and understand the logical representation of data.

Let’s get to the JSON structure.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{
  "Actors": [
    {
      "id": "1",
      "firstName": "Tom",
      "lastName": "Cruise"
    },
    {
      "id": "2",
      "firstName": "James",
      "lastName": "Bond"
    }
  ]
}

This example shows the Actors’ data and has two actors. It’s easy to understand along with that it takes less space to store in memory than XML.

Above JSON data consists of an array of Actors and each actor is value in JSON Array. Looks complicated?

Let’s understand all the data type JSON has, to represent the data.

JSON Data Types

  • Number
  • String
  • Boolean
  • Array
  • Object
  • Null

This example uses all the JSON data types.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
  "id": 1,
  "age": 30,
  "Name": "James Bond",
  "Address" :[
      {
        "city":"Los Angels",
        "country": "USA"
      },
      {
        "city":"London",
        "country": "UK"
      }
    ],
  "wife":null,
  "ishavingmobile":true,
  "firstmovie" :{
    "name":"Dr. No",
    "releaseyear":1962
  }
 
}

I hope you are having an understanding of JSON now. Let me know if you have any questions about JSON in the comment sections, I am happy to help. You can also play with JSON data at https://jsonformatter.org

Other JSON related articles.

Validate JSON using Javascript

JSON Examples with all Data Types

Sharing is caring!