所以让我们假设我有一个这样的 JSON 文件:
{ "store": {
"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{ "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",
"price": 8.99
},
{ "category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
]
}
}
我想要做的是抓住“书”的成员及其所有字符串值对,其中标题是“荣誉之剑”。我怎么能用 JQuery 做到这一点?问题是我不知道成员的索引 ID,如果我知道这将是微不足道的,即 store.book[1].XXX 会给我我正在寻找的所有兄弟键值对的值为了。
关于如何用最少的代码做到这一点的任何想法?