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 (aka key/value pairs).
A name/value pair consists of a field name (in double quotes), followed by a colon, followed by a value:
JSON names require double quotes.
In JSON, keys must be strings, written with double quotes:
In JSON, values must be one of the following data types:
- a string
- a number
- an object
- an array
- a boolean
- a function
- a date
In JSON, string values must be written with double quotes:
It can also be accessed like this:
Data can be modified like this:
It can also be modified like this:
You will learn more about objects and arrays later in this tutorial.
- The file type for JSON files is ".json"
- The MIME type for JSON text is "application/json"