鉴于test.json
我从 Pocket API 收到的以下响应,
{
"complete": 1,
"error": null,
"list": {
"1000055792": {
"excerpt": "Some Text",
"favorite": "0",
"given_title": "Some Title",
"given_url": "Some URL",
"has_image": "0",
"has_video": "0",
"is_article": "1",
"is_index": "0",
"item_id": "1000055792",
"resolved_id": "1000055792",
"resolved_title": "Title",
"resolved_url": "Some URL",
"sort_id": 700,
"status": "1",
"time_added": "1438646514",
"time_favorited": "0",
"time_read": "1439025088",
"time_updated": "1439025090",
"word_count": "10549"
},
"1000102810": {
"excerpt": "Some Text",
"favorite": "0",
"given_title": "Title",
"given_url": "Some URL",
"has_image": "1",
"has_video": "0",
"is_article": "1",
"is_index": "0",
"item_id": "1000102810",
"resolved_id": "1000102810",
"resolved_title": "Title",
"resolved_url": "Resolved URL",
"sort_id": 650,
"status": "1",
"time_added": "1440303789",
"time_favorited": "0",
"time_read": "1440320729",
"time_updated": "1440320731",
"word_count": "3219"
}
如何访问键的值,例如resolved_title
和word_count
。它们嵌套在一个数字对象内,与 一样id
,它本身嵌套在 内list
。我已经搜索并找到了一种使用 jq 访问嵌套对象的方法。但是如何访问嵌套在主list
对象内另一个对象内的值?
此外,ID 是不同的并且不是连续的,所以我认为递归是不可能的,但我可能是错的。我打算用这些数据做的是只提取每个项目的resolved_title
和word_count
值并将它们保存到一个两列的电子表格中。
提前致谢!