js 判断json是否有某个属性

js 判断json是否有某个属性

json格式的数据 一般就是[Object]对象

只能通过遍历来查询里面的东西

假设我们要查询json数据 (假设是vars)里面是否有name的属性(key)代码如下

$.each(v.vars,
function(varKey, varValue) {
if (varKey == 'name') {
alert('yes')
}
});