-
Notifications
You must be signed in to change notification settings - Fork 0
/
intro-json.txt
33 lines (26 loc) · 1 KB
/
intro-json.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// JSON : JavaScript Object Notation
// Implication: a JSON object is also a valid javascript object
// Example 1.
// Remember objects from the js class?
// var human = { name: 'Vera Michael', aka: 'V-money', gender: 'female' };
// representing that in JSON is the same thing, except that you need to lose the
// extra 'var human =' part.
// here's the human object in JSON
{
"name": "Vera Michael",
"aka": "V-money",
"gender": "Female"
}
// unlike in js, there are no 'methods' in JSON, so the human here cannot talk()
// Example 2. Json Array
// This is an array of values
[ "Father", "Mother", 32, "Children", true, false ]
// No semicolon terminating each line in JSON
// This is an array of objects
[
{ "name": "Ife Dayo", "aka": "Ifedy", "gender": "Male" },
{ "name": "David Omotosho", "aka": "Dylectus", "gender": "Male" },
{ "name": "Bola Ajayi", "aka": "Bee", "gender": "Female" }
]
// the last array above contains three (human) objects, each of which have their
// defining properties.