JSON
JSON is a simple yet very useful way of storing data. It's a plain-text file with some structured data inside.
There are six types in JSON: number (integer/float), object, array, boolean, null, and string.
-
Object β¨. An object is wrapped inside
{}
. It's a structure with keys that are associated with a value.
{
"key": 1,
"key2": "string",
"key3": false,
"key4": { "key1": "string" },
"key5": [],
"key6": null
}
- Array π€: simply an array of values
[
42,
"string",
true,
null,
{ "key1": "value" },
[]
]
- Example π: a list (array) of users (objects)
[
{ "username": "toto", "password": "toto" },
{ "username": "tata", "password": "tata" },
{ "username": "titi", "password": "titi" }
]
Extensions
JSON5
Some are not satisfied with the limited syntax of JSON. Here are some limitations:
- βοΈ You can't use comments (
// comment
) in JSON - π‘ There are no multiline strings, so it's not easy to read/write long strings in JSON. A good editor would have a feature to wrap the JSON, to avoid very long lines
- ...
So, they created JSON5. It's not quite used widely.
GeoJSON
"GeoJSON is a format for encoding a variety of geographic data structures".
- See geojson
- Not tested (π»)