js取json对象的键和值
//构建一个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对象的值
}