鉴于我从掌上API的响应收到以下test.json
,如何提升嵌套两层深度的JSON对象的值?
{
"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
值,并将它们保存为两列电子表格。
在此先感谢!
什么语言你在做这个吗? JavaScript的?你添加了“命令行”标签,那么你是否使用node.js?或其他一些语言? –
@KenB问题和标签都提及[标签:jq] – tripleee
啊对不起,我以为'jq'意味着jQuery,现在我看到它是一个命令行工具用于浏览JSON –