[英]How to get/list all field names of a JSON data with ExtJS?
I have this json data: 我有这个json数据:
[
{"ID":"1","name":"google","IP":"69.5.33.22","active":"true"},
{"ID":"2","name":"bing","IP":"70.5.232.33","active":"false"}
]
I want to get the all property names (?), like: 我想获取所有属性名称(?),例如:
name,ID,IP,active 姓名,ID,IP,活跃
Note: I don't mind what is there at "name" and "IP" like google, 70.5.232.33, etc. Just, I want to get the fields itself. 注意:我不介意Google,70.5.232.33等“名称”和“ IP”中包含什么。只是,我想获取字段本身。
var jsonString = [
{"ID":"1","name":"google","IP":"69.5.33.22","active":"true"},
{"ID":"2","name":"bing","IP":"70.5.232.33","active":"false"}
];
var keyArray = Ext.Object.getKeys(Ext.JSON.decode(jsonString));
console.log(keyArray) // ["ID","name","IP","active"]
Iterate over the object after you've parsed it. 解析对象后,对其进行迭代。
js> for(i in {"ID":"1","name":"google","IP":"69.5.33.22","active":"true"})
{
print(i);
}
ID
name
IP
active
js>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.