【发布时间】:2016-11-05 03:17:40
【问题描述】:
鉴于下面的 JSON:
{
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century"
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{
"category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3"
},
{
"category": "fiction",
"author": "J. R. R. Tolkien",
"title": null,
"isbn": "0-395-19395-8",
"price": null
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}
我可以使用什么 JSON 路径来检索包含 category、author、price 和 title 参数的 book 的第一个元素?需要明确的是,我不想要 任何 category、author、price 和 title 参数——只有那些来自单个书籍对象的参数。此外,book 数组的结构会有所不同(即其元素的数量和配置会随着时间而变化),因此我无法真正硬编码任何内容。
【问题讨论】: