【发布时间】:2017-03-19 05:49:08
【问题描述】:
我想检查如下 JSON 对象中的某个键是否包含某个值。假设我想检查任何对象中的键“名称”是否具有值“Blofeld”(这是真的)。我该怎么做?
[ {
"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
} ]
【问题讨论】:
-
obj.name === "Blofeld"
标签: javascript json object key