JSON - ilya-khadykin/notes-outdated GitHub Wiki
JSON
JSON is a standart format used to transfer data over the network. JSON is pretty much just JavaScript object literals with a few reasonable restrictions, such as:
- you must use quotation marks for JavaScript object keys;
- valid values for a given key can only be a string, number, boolean (true or false), array,
null
, or another valid JSON object; - the last property must not have an extra comma:
// Invalid JSON
{
"foo": "123",
"bar": "123",
}
// Valid JSON
{
"foo": "123",
"bar": "123"
}
Example of a valid JSON object
{
"firstName": "John",
"lastName": "Smith",
"isAlive": true,
"age": 25,
"height_cm": 167.64,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
},
"phoneNumbers": [
{ "type": "home", "number": "212 555-1234" },
{ "type": "fax", "number": "646 555-4567" }
],
"additionalInfo": null
}