What is JSON?

 JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write.

It is mainly used to store data in document databases and transport data between different applications, primarily servers and web applications.


JSON is also frequently used in RESTFul APIs to provide data in the request and response body. Below is an example JSON document summarizing a menu of a restaurant.




JSON supports the following two data structures;

  1. Collection of name/value pairs
  2. An ordered list of values − It includes arrays, lists, sequences, etc.
A name/value pair consists of a field name (in double quotes), followed by a colon, followed by a value. So in the below example, the name is “firstName”, and the value is “John”.

Example: “firstName”: “John”

You need to put text values between double quotes. You do not need double quotes for numbers, boolean values, or null values.

Example: “age”: 24

In JSON, values must be one of the following data types:

String — Strings in JSON must be written in double quotes
Number — Numbers in JSON must be an integer or a floating-point
Object (JSON object) — Values in JSON can be objects. However, objects as values in JSON must follow the same rules as JSON objects.
Array — Values in JSON can be arrays. Array values are provided between []
Boolean — Either true or false value
Null — Empty value or no value


**********************************
**********************************

*************************


No comments:

Post a Comment