Gnanam kalai
2 min readFeb 18, 2021

--

Work With JSON Data

Data transfer is the most important process in web technology. Most of the applications we used are transferring data between servers and client devices or front end. exchanging data between a browser and a server is an important part of web development. To transfer data from backend to frontend need to use one of the efficient ways.

So efficient data transferring methods want to be used for effective results.it is easy to transfer single values as text or string but if we send a collection of data or complex data as a string it is not easy to fetch all values from a string. Therefore data shared by different formats. The widely used format for transforming data between resources is JSON.

JSON stands for JavaScript Object Notation. It is a text base data format and collection of data pairs and ordered lists. It is a human readable format to store and transmit data. It closely resembles JavaScript object literal syntax, it can be used independently from JavaScript, and many programming environments.

JSON exists as a string and it is really useful for transmitting data across the network. It needs to convert to a JS object when we want to access the data. Converting a string to a native object is called deserialization, while converting a native object to a string so it can be transmitted across the network is called serialization.

JSON structure

As noted above JSON very much resembles JS object format. It can include the same basic data types as JS objects in JSON. A JSON value can be string, number, JSON object, array, boolean and null. the data hierarchy like as

{

“Name” : “Kalairaj” ,

“Age” : 24 ,

“Active” : true ,

“Subject” [

{

“Name” : “Maths”,

“Marks” : 80

},

{

“Name” : “Physics”,

“Marks” : 90

}

]

}

To convert this string format to JS objects we can use javascript function JSON.parse( ) .

For example to convert this JSON text format ‘{ “name”:”kalairaj”, “age”:24, “city”:”mullaitivu”}’ to javascript object we can use JSON. parse function like as bellow

var js_object = JSON.parse(‘{ “name”:”kalairaj”, “age”:24, “city”:”mullaitivu”}’);

Now the JSON converted to js object.

Then

How to use this js object?

We can use this object to retrieve values like js_object.name , js_object.age , js_object.city.

How to convert a js object to JSON?

Yes. Another function to convert js objects to string is JSON.stringify().

For example

var object = { name: “kalairaj”, age: 24, city: “mullaitivu” };

If we want to convert the js object above to json string we can use JSON.stringify() like this

var JSON = JSON.stringify(object);

These are the main functions that are enabled to convert and manipulate data in JSON format.

--

--