//构建一个json对象
var pinpai = {
"0":{"美的":49,"三星":35,"海信":25,"格力":16,"方太":14},
"1":{"美的":49,"三星":35,"海信":25,"格力":16,"方太":14}
};
jiage = pinpai[0]['美的'];
源:
//构建一个json对象
var jb={"美的":49,"三星":35,"海信":25,"格力":16,"方太":14};
for(var key in jb){
alert(key); //json对象的key
alert(jb[key]); //json对象的值
}
var id = 2;
var name = "";
var index = test.findIndex((v,i)=>v.id == id);
if(index >= 0)
name = test[index].name;