What is JSON?
JSON or JavaScript Object Notation is a format for structuring data.
What is it used for?
Like XML, it is one of the way of formatting the data. Such format of data is used by web applications to communicate with each other.
Characteristics of JSON
- It is Human-readable and writable.
- It is light weight text based data interchange format which means, it is simpler to read and write when compared to XML.
- Though it is derived from a subset of JavaScript, yet it is Language independent. Thus, the code for generating and parsing JSON data can be written in any other programming language.
JSON Syntax Rules
JSON syntax is derived from JavaScript object notation syntax:
- Data is in name/value pairs
Example:
{ “name”:”Thanos” }
Types of Values:
Array: An associative array of values.
Boolean: True or false.
Number: An integer.
Object: An associative array of key/value pairs.
String: Several plain text characters which usually form a word. - Data is separated by commas
Example:{ “name”:”Thanos”, “Occupation”:”Destroying half of humanity” }
- Curly braces hold objects
Example:var person={ “name”:”Thanos”, “Occupation”:”Destroying half of humanity” }
- Square brackets hold arrays
Example:var person={ “name”:”Thanos”, “Occupation”:”Destroying half of humanity”,
“powers”:
[“Can destroy anything with snap of his fingers”,
“Damage resistance”, “Superhuman reflexes”] }
Here person is the object.
Here person is the object and powers is an array.
Examples:
{ "Avengers": [ { "Name" : "Tony stark", "also known as" : "Iron man", "Abilities" : [ "Genius", "Billionaire", "Playboy", "Philanthropist" ] }, { "Name" : "Peter parker", "also known as" : "Spider man", "Abilities" : [ "Spider web", "Spidy sense" ] } ] } |
Recommended Posts:
- How to convert JSON string to array of JSON objects using JavaScript ?
- JSON | modify an array value of a JSON object
- Javascript | JSON PHP
- Converting JSON text to JavaScript Object
- JavaScript JSON stringify() Method
- JavaScript | JSON HTML
- JavaScript | JSON Arrays
- Deserializing a JSON into a JavaScript object
- JavaScript JSON parse() Method
- JavaScript | Remove a JSON attribute
- JavaScript | Check if a string is a valid JSON string
- JavaScript | Convert an array to JSON
- JavaScript | Add new attribute to JSON object
- JavaScript | How to add an element to a JSON object?
- JavaScript | Check if a key exists inside a JSON object
- How to pretty print JSON string in JavaScript ?
- How to convert PHP array to JavaScript or JSON ?
- How to convert JSON data to a html table using JavaScript/jQuery ?
- How to Convert JS Object to JSON String in JQuery/Javascript?
- How to send a JSON object to a server using Javascript?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


