JSON是一種輕量級的資料交換語言,以文字為基礎,且易於讓人閱讀。
在此將JSON格式簡化並定義如下,
一個JSONObject由一組大括號和若干組key,value組成,形如:
範例1:
定義:
本題要維護一個JSONObject,對其操作以遞迴定義如下:
範例請見範例輸入
每組測試資料只包含一筆,所有key字串和value字串長度≤10,insert次數≤1000,保證同一個JSONObject中不會出現兩個以上(含)同樣的key,所有操作絕對合法,輸入格式如題目敘述
輸出維護的JSONObject,適當補上大括號和逗號,並依照插入順序列出其Key:Value,冒號前後不含空白,不須換行且不需縮排,見範例輸出。
insert "Name" "Alan" insert "Age" "19" insert "Score" newJSONObject insert "Math" "98" insert "Physics" "100" end insert "Gender" "male" end
{"Name":"Alan","Age":"19","Score":{"Math":"98","Physics":"100"},"Gender":"male"}
origin | {} |
insert "Name" "Alan" | {"Name":"Alan"} |
insert "Age" "19" | {"Name":"Alan","Age":"19"} |
insert "Score" newJSONObject | {"Name":"Alan","Age":"19","Score":{}} |
insert "Math" "98" | {"Name":"Alan","Age":"19","Score":{"Math":"98"}} |
insert "Physics" "100" | {"Name":"Alan","Age":"19","Score":{"Math":"98","Physics":"100}} |
end | {"Name":"Alan","Age":"19","Score":{"Math":"98","Physics":"100}} |
insert "Gender" "male" | {"Name":"Alan","Age":"19","Score":{"Math":"98","Physics":"100},"Gender":"male"} |
end | {"Name":"Alan","Age":"19","Score":{"Math":"98","Physics":"100},"Gender":"male"} |
編號 | 身分 | 題目 | 主題 | 人氣 | 發表日期 |
沒有發現任何「解題報告」
|