JS Tutorial
Menu
JS Version
Menu
JS Objects
Menu
JS Function
Menu
JS Classes
Menu
JS Async
Menu
JS HTML DOM
Menu
JS Browser BOM
Menu
JS Web API
Menu
JS AJAX
Menu
JS JSON
Menu
JS vs JQUERY
Menu
JS Graphics
Menu
JavaScript JSON
JSON is a syntax for storing and transporting data.
JSON is used when data is sent from a server to a web page.
What is JSON?
- JSON stands for JavaScript Object Notation.
- JSON is a lightweight data interchange format.
- JSON is language independent *.
- JSON is “self-describing” and easy to understand.
* The JSON syntax is derived from JavaScript object notation syntax, but the JSON format is text only.
JSON Example
This JSON syntax specifies an employees object: an array of 3 employee records (objects):
{
“employees”:[
{“firstName”:”John”, “lastName”:”Doe”},
{“firstName”:”Anna”, “lastName”:”Smith”},
{“firstName”:”Peter”, “lastName”:”Jones”}
]
}
The JSON Format Evaluates to JavaScript Objects
The JSON format is similar to the code for creating JavaScript objects.
Due to this similarity, a JavaScript program can be used to convert JSON data into native JavaScript objects.
JSON Syntax Rules
- Data is in name/value pairs.
- Data is separated by commas.
- Curly braces hold objects.
- Square brackets hold arrays.