I have JSON file in below format. I want to get value ie (mouse, aets, infor) using key values.
{
"list": [
{
"item_alias_list": "mouse",
"eancode": "19",
},
{
"item_alias_list": "aets",
"eancode": "11",
},
{
"item_alias_list": "infor",
"eancode": "23",
}
]
}
var a = {"list":[
{
"item_alias_list":"mouse",
"eancode":"19",
}
, {
"item_alias_list":"aets",
"eancode":"11",
}
, {
"item_alias_list":"infor",
"eancode":"23",
}
]};
// get "mouse"
var ret = a.list[0].item_alias_list;
删除有效JSON的数字字符串后的逗号
you can try this
suppose
var Data =
{"list":[{"item_alias_list":"mouse","eancode":"19"},
{"item_alias_list":"aets","eancode":"11"},
{"item_alias_list":"infor","eancode":"23"}]
};
var len = Data.list.length;
for(var i = 0; i<len; i++)
{
for(var key in Data.list[i])
{
alert(key +"="+ Data.list[i][key])
}
}
live Demo : http://jsfiddle.net/PQcFx/40/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.