Json

What is Json ? explain its functionality ?

Last updated:7/3/2018 3:36:27 AM

1 Answers

Prakash nidhi Verma
Prakash nidhi Verma

JSON :

JSON stands for JavaScript Object Notation.

JSON is a lightweight data-interchange format .

JSON is 'self-describing' and easy to understand .

JSON is language independent.

We can also convert any JSON received from the server into JavaScript objects If you have data stored in a JavaScript object, you can convert the object into JSON, and send it to a server: 

- Exchanging Data. 

- Sending Data

var myObj = { 'name':'Prakash', 'age':19, 'city':'Allahabad' }; 
var myJSON = JSON.stringify(myObj);
window.location = 'demo_json.php?x=' + myJSON;

- Receiving Data 

var myJSON = '{ 'name':'Prakash', 'age':19, 'city':'Allahabad' }'; 
var myObj = JSON.parse(myJSON); document.getElementById('demo').innerHTML = myObj.name; 

- Storing Data

//Storing data in local server:

myObj = { 'name':'Prakash', 'age':19, 'city':'Allahabad' };
myJSON = JSON.stringify(myObj);
localStorage.setItem('testJSON', myJSON);

Answer