跳轉到內容

JSON/資料型別

來自華夏公益教科書,開放的書籍,開放的世界

快速回顧

[編輯 | 編輯原始碼]

JSON 是一種儲存資料的表示語言。一個例子是儲存 playerData。

資料型別

[編輯 | 編輯原始碼]

整數很容易建立。只需輸入整數即可!

2, 10, 5

字串用雙引號括起來

"Hello, World!"

布林值要麼為真,要麼為假

true

陣列實際上就是資料的列表。

[1, 3, 10, 15]
["Hello","Goodbye","World"]

要從陣列中獲取資料,請執行以下操作

array = ["Hello","World"] 
string0 = array[0] // array[0] = "Hello"
string1 = array[1] // array[1] = "World"
string2 = string0 + " " + string1 // Hello World

最棒的是!物件,物件是 JSON 的核心。沒有物件就無法使用 JSON!要建立物件,只需新增花括號和(我想不出什麼,我將在程式碼中展示)

{
    "MyName": "Streamer",
    "MyPassword": "catinabowl"
}
華夏公益教科書