JSON Syntax Rules
- 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.
A name/value pair consists of a field name (in double quotes), followed by a colon, followed by a value:
JSON values can be:
- A number (integer or floating point)
- A string (in double quotes)
- A Boolean (true or false)
- An array (in square brackets)
- An object (in curly braces)
JSON objects are written inside curly braces.
JSON arrays are written inside square brackets.
In the example above, the object "employees" is an array containing three objects. Each object is a record of a person (with a first name and a last name).
employees.firstName + " " + employees.lastName;
It can also be accessed like this:
employees["firstName"] + " " + employees["lastName"];
Data can be modified like this:
It can also be modified like this:
- The file type for JSON files is ".json"
- The MIME type for JSON text is "application/json"