###### tags: `JSON`
JSON
===
[Learn JSON in 10 Minutes](https://www.youtube.com/watch?v=iiADhChRriM)
- JSON
JavaScript Object Notation
- DATA REPRESENTATION FORMAT
- commonly used for apis and configs
- lightweight and easy to read/write
- intergrate easily with most languages
- Types
- Strings
"hello World" "kyle" "l"
- Numbers
"10","1.5","-30"
- Booleans
True False
- null
null
- Arrays
[1, 2, 3]
- objects
{"key":"value"} {"age":"30"}
- example'
可以放入各式各樣的東西,Dictionary裡面還可以放array,每一個中間元素要用,隔開,最後一個不用放。
---
```
{
"name":"kyle",
"favorite": 3,
"isProgrammer": true,
"hobbies": ["Weight" Lifting, "Bowling"],
"friends": [{
"name": "Joey",
"favoriteNumber": 100,
"isProgramming": false,
"friends":["Sally", "bally", "kitty"]
}]
}
```
- 也可以用下列方式整理多間公司的資料
```
' [
{
"name":"BIG Corporation ",
"numberOfEmployees": 10000,
"ceo": "Mary",
"rating": 3.6
},
{
"name":"Small Startup",
"numberOfEmployees":3 ,
"ceo": null,
"rating":4.3
}
]'
```
但若是要用在Java裡面,需要使用''把他包起來,這樣才可以變成string的方式。
最後使用JSON.Parse(檔案名稱)把他順利地變成一個物件,可以方便使用。
- Conclusion
這樣的使用方式,可以方便網路上傳輸,用各種API的方式來做傳送,每個key跟Value上面都可以清楚的看到所有的資訊內容跟代表的事件,讓終端使用者都可以迅速的採用跟閱讀。