如何访问以下JSON数组中的值标签
[ { _id: 596e0053e405e523bca7d289,
'[{"type":"button","label":"Button","subtype":"button","className":"btn-
default btn","name":"button-1500381266064","style":"de
fault"}]': '' },
{ _id: 596e0053e405e523bca7d28a } ]
答案 0 :(得分:0)
据我所知,你的JSON是属性的名称,鉴于GUID是以字符串形式提供的,这应该有效:
var t=[ { _id: '596e0053e405e523bca7d289',
'[{"type":"button","label":"Button","subtype":"button","className":"btn-default btn","name":"button-1500381266064","style":"default"}]': '' },{ _id: '596e0053e405e523bca7d28a' } ]
function propName(prop, value){
for(var i in prop) {
if (prop[i] == value){
return i;
}
}
return false;
}
console.log(JSON.parse(propName(t[0], ""))[0].label)