我想檢查下面的JSON對象中的某個鍵是否包含某個值。假設我想檢查任何對象中的鍵「name」是否具有值「Blofeld」(這是正確的)。我怎樣才能做到這一點?使用Javascript檢查JSON對象是否包含值
[ {
"id" : 19,
"cost" : 400,
"name" : "Arkansas",
"height" : 198,
"weight" : 35
}, {
"id" : 21,
"cost" : 250,
"name" : "Blofeld",
"height" : 216,
"weight" : 54
}, {
"id" : 38,
"cost" : 450,
"name" : "Gollum",
"height" : 147,
"weight" : 22
} ]
[有沒有這樣的事情作爲一個 「JSON對象」(http://benalman.com/news/2010/03/theres-no-such-thing-as-a-json /) – adeneo
'obj.name ===「Blofeld」' – vlaz
['Array.prototype.some()'](https://developer.mozilla .org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/some) – Andreas