AppInventor2操作json資料
阿新 • • 發佈:2021-06-16
AppInventor2操作json資料
測試的json文字:
{ "data": [ { "pinned": false, "post_hint": "rich:video", "preview": { "enabled": false, "images": [ { "id": "kFH7UID4C_mvoYUHTD-Oqf8AZ1CV-ooWlUykcZg1fbg", "resolutions": [ { "height": 81, "url": "https://external-preview.redd.it/pFxri6KVX9ZHpHH6pR2J_BG3k_wEqvLZo69i2ipyA3Q.jpg", "width": 108 }, { "height": 162, "url": "https://external-preview.redd.it/pFxri6KVX9ZHpHH6pR2J_BG3k_wEqvLZo69i2ipyA3Q.jpg", "width": 216 }, { "height": 240, "url": "https://external-preview.redd.it/pFxri6KVX9ZHpHH6pR2J_BG3k_wEqvLZo69i2ipyA3Q.jpg", "width": 320 } ], "source": { "height": 360, "url": "https://external-preview.redd.it/pFxri6KVX9ZHpHH6pR2J_BG3k_wEqvLZo69i2ipyA3Q.jpg", "width": 480 }, "variants": {} } ] }, "pwls": 6, "retrieved_on": 1623815633, "score": 61, "secure_media": { "oembed": { "author_name": "nipafx", "author_url": "https://www.youtube.com/c/nipafx", "height": 200, "provider_name": "YouTube", "provider_url": "https://www.youtube.com/", "thumbnail_height": 360, "thumbnail_url": "https://i.ytimg.com/vi/KG24inClY2M/hqdefault.jpg", "thumbnail_width": 480, "title": "The State of Project Loom with Ron Pressler", "type": "video", "version": "1.0", "width": 356 }, "type": "youtube.com" }, "secure_media_embed": { "height": 200, "media_domain_url": "https://www.redditmedia.com/mediaembed/o0m6g8", "scrolling": false, "width": 356 }, "selftext": "", "send_replies": true, "spoiler": false, "stickied": false, "subreddit": "java", "subreddit_id": "t5_2qhd7", "subreddit_subscribers": 234484, "subreddit_type": "public", "thumbnail": "image", "thumbnail_height": 105, "thumbnail_width": 140, "title": "The State of Project Loom with Ron Pressler", "total_awards_received": 0, "treatment_tags": [], "upvote_ratio": 0.92, "url": "https://www.youtube.com/watch?v=KG24inClY2M", "url_overridden_by_dest": "https://www.youtube.com/watch?v=KG24inClY2M", "whitelist_status": "all_ads", "wls": 6 } ] }
目的:獲取紅框資料(以列表型別儲存)
基本的程式碼塊為:
獲取不同層次裡的資料只需在建立列表處更改程式碼:
每深入一層則在建立列表處向下新增路徑,遇到中括號則需要用到 “本層所有鍵” 這個模組。
1.第一種情況:
程式碼塊:
2.第二種情況:
程式碼塊:
3.第三種情況:
程式碼塊:
4.第四種情況:
程式碼塊:
5.第五種情況:
程式碼塊: