我已經打了corona
和dropbox
,我也得到類似的結果來自收件箱科羅納/ JSON結果
下面我將它們保存在一個變量t
t='{
"revision": 7,
"rev": "707b638c6",
"thumb_exists": false,
"bytes": 36,
"modified": "Fri, 24 Jan 2014 03:07:54 +0000",
"client_mtime": "Mon, 14 May 2012 18:56:57 +0000",
"path": "/mydays_b_12132012120312.txt",
"is_dir": false,
"icon": "page_white_text",
"root": "dropbox",
"mime_type": "text/plain",
"size": "36 bytes"
},
{
"revision": 9,
"rev": "907b638c6",
"thumb_exists": false,
"bytes": 36,
"modified": "Fri, 24 Jan 2014 03:08:03 +0000",
"client_mtime": "Mon, 14 May 2012 18:56:57 +0000",
"path": "/mydays_b_12122012120314.txt",
"is_dir": false,
"icon": "page_white_text",
"root": "dropbox",
"mime_type": "text/plain",
"size": "36 bytes"
},
{
"revision": 12,
"rev": "c07b638c6",
"thumb_exists": false,
"bytes": 36,
"modified": "Fri, 24 Jan 2014 18:51:43 +0000",
"client_mtime": "Mon, 14 May 2012 18:56:57 +0000",
"path": "/mydays_b_12132012120319.txt",
"is_dir": false,
"icon": "page_white_text",
"root": "dropbox",
"mime_type": "text/plain",
"size": "36 bytes"
}'
我想提取所有「path
」這樣的結果我有
/mydays_b_12132012120312.txt
/mydays_b_12122012120314.txt
/mydays_b_12132012120319.txt
我試圖corona json api
local decode = json.decode(t)
print(decode.path)
,但我只得到了第一個路徑提取...
任何想法?
我也可以用另一種結果
t='{
"hash": "c6e5643fe351d4a59b4b3cb61bdfb870",
"thumb_exists": false,
"bytes": 0,
"path": "/",
"is_dir": true,
"size": "0 bytes",
"root": "app_folder",
"contents": [{
"revision": 1,
"rev": "107b638c6",
"thumb_exists": false,
"bytes": 36,
"modified": "Mon, 14 May 2012 18:56:57 +0000",
"client_mtime": "Mon, 14 May 2012 18:56:57 +0000",
"path": "/backup.txt",
"is_dir": false,
"icon": "page_white_text",
"root": "dropbox",
"mime_type": "text/plain",
"size": "36 bytes"
},
{
"revision": 9,
"rev": "907b638c6",
"thumb_exists": false,
"bytes": 36,
"modified": "Fri, 24 Jan 2014 03:08:03 +0000",
"client_mtime": "Mon, 14 May 2012 18:56:57 +0000",
"path": "/mydays_b_12122012120314.txt",
"is_dir": false,
"icon": "page_white_text",
"root": "dropbox",
"mime_type": "text/plain",
"size": "36 bytes"
},
{
"revision": 7,
"rev": "707b638c6",
"thumb_exists": false,
"bytes": 36,
"modified": "Fri, 24 Jan 2014 03:07:54 +0000",
"client_mtime": "Mon, 14 May 2012 18:56:57 +0000",
"path": "/mydays_b_12132012120312.txt",
"is_dir": false,
"icon": "page_white_text",
"root": "dropbox",
"mime_type": "text/plain",
"size": "36 bytes"
}],
"icon": "folder"
}'
工作,但似乎並不容易。
這將是巨大的,如果youu可以給我兩個解決方案,最終得到所有「路徑」的結果
非常感謝 克里斯
第一't'不是有效的JSON字符串。它似乎是一個對象列表,但在那裏沒有數組符號。也許科羅納只返回第一個,因爲它沒有將輸入作爲數組處理。 –