【JS】重零學習- Day13-Json

json 是什麼?

JavaScript Object Notation

object

JSON格式簡單來說,就是這二句重點:

物件(object)大括號 { }

value

陣列(array)中括號 [ ]

array

線上都有提供這個parser 

1. Json Parser Online     

2. JSON Editor Online 

範例格式如下:

{
     "firstName": "John",
     "lastName": "Smith",
     "sex": "male",
     "age": 25,
     "address": 
     {
         "streetAddress": "21 2nd Street",
         "city": "New York",
         "state": "NY",
         "postalCode": "10021"
     },
     "phoneNumber": 
     [
         {
           "type": "home",
           "number": "212 555-1234"
         },
         {
           "type": "fax",
           "number": "646 555-4567"
         }
     ]
 }

這樣看起來 像不像一個物件,

參考資料 :

政府資料開放平台 

MDN