1[
2 {
3 "id": "0001",
4 "type": "donut",
5 "name": "Cake",
6 "ppu": 0.55,
7 "batters":
8 {
9 "batter":
10 [
11 { "id": "1001", "type": "Regular" },
12 { "id": "1002", "type": "Chocolate" },
13 { "id": "1003", "type": "Blueberry" },
14 { "id": "1004", "type": "Devil's Food" }
15 ]
16 },
17 "topping":
18 [
19 { "id": "5001", "type": "None" },
20 { "id": "5002", "type": "Glazed" },
21 { "id": "5005", "type": "Sugar" },
22 { "id": "5007", "type": "Powdered Sugar" },
23 { "id": "5006", "type": "Chocolate with Sprinkles" },
24 { "id": "5003", "type": "Chocolate" },
25 { "id": "5004", "type": "Maple" }
26 ]
27 },
28 {
29 "id": "0002",
30 "type": "donut",
31 "name": "Raised",
32 "ppu": 0.55,
33 "batters":
34 {
35 "batter":
36 [
37 { "id": "1001", "type": "Regular" }
38 ]
39 },
40 "topping":
41 [
42 { "id": "5001", "type": "None" },
43 { "id": "5002", "type": "Glazed" },
44 { "id": "5005", "type": "Sugar" },
45 { "id": "5003", "type": "Chocolate" },
46 { "id": "5004", "type": "Maple" }
47 ]
48 },
49 {
50 "id": "0003",
51 "type": "donut",
52 "name": "Old Fashioned",
53 "ppu": 0.55,
54 "batters":
55 {
56 "batter":
57 [
58 { "id": "1001", "type": "Regular" },
59 { "id": "1002", "type": "Chocolate" }
60 ]
61 },
62 "topping":
63 [
64 { "id": "5001", "type": "None" },
65 { "id": "5002", "type": "Glazed" },
66 { "id": "5003", "type": "Chocolate" },
67 { "id": "5004", "type": "Maple" }
68 ]
69 }
70]
71
1{
2 "first_name": "Taylor",
3 "last_name": "Hawkes",
4 "age": 31,
5 "address": {
6 "street": "954 Kazaam Lane",
7 "city": "Boulder",
8 "state": "CO",
9 "postalCode": "80303"
10 },
11 "emails": [
12 {
13 "type": "main",
14 "number": "th71852@gmail.com"
15 },
16 {
17 "type": "secondary",
18 "number": "taylordhawkes@gmail.com"
19 }
20 ]
21}
1{
2 "quiz": {
3 "sport": {
4 "q1": {
5 "question": "Which one is correct team name in NBA?",
6 "options": [
7 "New York Bulls",
8 "Los Angeles Kings",
9 "Golden State Warriros",
10 "Huston Rocket"
11 ],
12 "answer": "Huston Rocket"
13 }
14 },
15 "maths": {
16 "q1": {
17 "question": "5 + 7 = ?",
18 "options": [
19 "10",
20 "11",
21 "12",
22 "13"
23 ],
24 "answer": "12"
25 },
26 "q2": {
27 "question": "12 - 8 = ?",
28 "options": [
29 "1",
30 "2",
31 "3",
32 "4"
33 ],
34 "answer": "4"
35 }
36 }
37 }
38}
39
1JavaScript Object Notation
2 Its a key value pair
3 its popular light-weight way of transfering data
4
5 for example :
6 Lets try to create a json for Person Object
7 with name , age , isMarried , gender
8
9 Its ket value pair
10 the key is always String and need to be in quotation
11 value can be :
12 String
13 Number
14 Boolean
15 null
16 array
17 another json object
18
19
20 This is one json with 5 fields
21 each key value pair should be separated by comma
22 {
23 "name" : "Anna",
24 "age" : 18 ,
25 "isMarried" : false ,
26 "gender" : "female",
27 "company" : null
28 }
1var myObj, x;
2myObj = {"name":"John", "age":30, "car":null};
3x = myObj.name;
4document.getElementById("demo").innerHTML = x;