You are on page 1of 3

Page 1

JSON

The JSON is a JavaScript object notation which is responsible for


passing and storing JavaScript values. The JSON is often used when
data is passed from server to the client side.

It is a kind of format for interchanging data between server and


client side. The JSON is self explanatory and easy to understand.

The JSON syntax is very simple, similar to the normal text with some
keys and values. These keys are used to specify unique data in the
JSON.

Characteristics of JSON:

 Readability: The JSON is very easy to read since it consist of


data format which is already been implemented by many
other programming languages. The format of JSON data
includes array and object type of data structure.

 Size: The size of JSON data is very less, tons of JSON data
would add up to few MBs of data. It is a lightweight data, text-
based format.

 Independent: The JSON language is an independent data, it is


not dependent on other languages to get implemented but
many other languages are dependent on JSON because it is

Copyright - Prolearninghub - All Rights Reserved.


Page 2

the easy to send and retrieve data between server and client
rather than using complex structure to send data to server.

Application of JSON:

There are few uses of JSON in an application but, JSON plays the
important role such as:

 When the JavaScript application includes browser extension


and websites, JSON comes into action.
 For serializing and transmitting data structure over network
JSON format is use.
 Developer prefers to use JSON to transmit data between server
and web application (mobile application).
 Web services such as Amazon, uses JSON format to provide
public data.
 It compatible with modern programming languages.

Syntax:
{
"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]
}

The syntax is defined by giving an example where an “employees”


array is a key. The array key consist of objects, in each object there

Copyright - Prolearninghub - All Rights Reserved.


Page 3

are two keys namely, “firstName” and “lastName”, mainly the above
syntax defines the information of the employee.

The JSON format is similar to the native JavaScript object and


because of that; it is very easy to convert JSON into the JavaScript
object.

Some rules of JSON are as follows:

 The data of JSON will contain key/value pair.


 The data is separated by commas.
 Presence of curly braces shows presence of object
 Presence of square braces shows presence of array

The data field inside JSON is similar to the javascript object. The data
field will consist of key/value pair. The syntax will be as follows: First
key name, followed by colon and then value of the key.

Syntax (JSON data field):

Key:value

For example:

“firstName”: “King”

The difference between JavaScript and JSON is that JSON requires


double quote to define a key.

Copyright - Prolearninghub - All Rights Reserved.

You might also like