What is 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 *
JSON uses JavaScript syntax, but the JSON format is text only.
Text can be read and used as a data format by any programming language.
The JSON format was originally specified by Douglas Crockford.
Why use JSON?
Since the JSON format is text only, it can easily be sent to and from a server and used as a data format by any programming language.
JavaScript has a built-in function to convert a string, written in JSON format, into native JavaScript objects:
JSON.parse()
So, if you receive data from a server, in JSON format, you can use it like any other JavaScript object.
The JSON syntax is a subset of the JavaScript syntax.
JSON Syntax Rules
JSON syntax is derived from JavaScript object notation syntax:
- Data is in name/value pairs
- Data is separated by commas
- Curly braces hold objects
- Square brackets hold arrays
JSON Data - A Name and a Value
JSON data is written as name/value pairs.