What is JSON ?

Learnwithshikha
2 min readMay 19, 2021

JSON stands for JavaScript Object Notation. It is easy for a user to read and write. It is a lightweight format, used for storing and transporting data. Data can be formatted using JSON. It looks like to object literal syntax. However, it is not just plain text data. Many times, it uses when data is sent from a server to a web page.

JSON Data

It is written as key and value pairs, just like JavaScript object properties. Key contains the name of the field, always in double-quotes. The value can be any data type as in the following table.

For Example:

{
"name": John,
"age": 31,
"gender": male
}

Keys

Key are “name”, “age”, and “gender’. It separated from the value by a colon. And each key and value pair is separated by a comma. However, remember there is no common after the last key and value pair.

Values

The value can be any of the following data types as shown in the following table.

string: Text must be written in double quotes.

number :Number.

boolean: true or false.

array: Array of value object. This can be contain child objects or array.

null: This is when the value in empty or missing.

JSON Syntax Rules

There are some rules as follow as.

  • Data is in key/value pairs
  • Separate data by commas(:)
  • Objects are written inside curly braces{}
  • Arrays must be written inside square brackets[].

JSON Objects

It written inside curly braces{}. AS JavaScript, objects can contain multiple name/value pairs:

For example:

{"firstName":"John", "age":"21"}

JSON Arrays

It written inside square brackets[]. Just like in JavaScript, an array can contain objects:

For example:

var text = '{"persons":[' +
'{ "name":"John" , "age":"24" },' +
'{ "name":"Annu" , "age":"30" },' +
'{ "name":"Ray" , "age":"32" }
]
}';

How JSON work with Data

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Learnwithshikha
Learnwithshikha

Written by Learnwithshikha

Hi, This is Shikha from India. I’m working as front-end developer besides a blogger. Here is my website https://learnwithshikha.com/

No responses yet

Write a response