JSON syntax rules
- Data is in name/value pairs
- Data is separated by commas
- Curly braces hold objects
- Square brackets hold arrays
"My name" : "Sanjeev"
{
"name" : "Sanjeev",
"age" : "29",
"registration number" : "1628634"
}
{
"name" : "Sanjeev",
"age" : "29",
"registration number" : "1628634"
}
[
{
"name" : "Sanjeev",
"age" : "29"
},
{
"name" : "Ranju",
"age" : "25"
},
{
"name" : "Anand",
"age" : "16"
},
{
"name" : "Richa",
"age" : "20"
}
]
- A name/value pair consists of
a field name or key (in double quotes),
followed by a colon,
followed by a value.
{ "name" : "Sanjeev" }
Types of Values in JSON
In JSON, values must be one of
the following data types:
- a string (Strings in JSON must be written in double quotes) {
"age" : "27"
}
- a number {
"age" : 27
}
- an object (JSON object) {
"age" : { "original" : "27",
"fake" : "26" }
}
- an array {
"age" : [ {"original" : "27", "fake" : "26"},
{"original" : "20", "fake" : "24"},
{"original" : "88", "fake" : "78"}
]
}
- a boolean {
"age" : true
}
- null {
"age" : null
}
JSON Files
- The file type for JSON files is ".json "
- The MIME type for JSON text is
"application/json"