# JSON
- Text | Language independent
- Better than XML
- Extension -
file.json
- MIME Type -
application/json
- Syntax
{
"persons": [
{ "name": "Foo", "age": 23 },
{ "name": "Bar", "age": 26 },
{ "name": "Baz", "age": 36 }
],
"Animals" ; {
"Birds": ["a", "b", "c"],
"Fishes": ["x", "y", "z"],
}
}
- Values
- Valid -
string. boolean, number, object, array, null
- Invalid -
function, date, undefined
- Valid -
- Object/Array --> JSON
// Obj => json
var obj = {"name":"foo", "age":23};
JSON.stringify(obj);
// Array => json
var arr = ['foo", "bar"]
JSON.stringify(arr);
- JSON --> Object
var Obj = JSON.parse(jsonData);