在jQuery $ .each中以JSON访问多个对象和数组

时间:2015-05-05 10:22:54

标签: jquery json

在jQuery $ .each

中访问JSON中的多个对象/数组
[{"APMUserObj":[{"APMUserId":6,"APMUserName":"sadasd asdasd"},
{"APMUserId":7,"APMUserName":"DWDWD DSDAWDASDASD"},
{"APMUserId":8,"APMUserName":"EWRWER EWRWER"},
{"APMUserId":9,"APMUserName":"tert rtert"},
{"APMUserId":11,"APMUserName":"vsfvd fgdfgdfhyrhr"},}],"CCUserObj":
[],"VoaUserObj":[]}

如何只为每个人嵌入ApmUserobj?

1 个答案:

答案 0 :(得分:0)

    var obj = {"APMUserObj":[
        {"APMUserId":6,"APMUserName":"sadasd asdasd"}
       ,{"APMUserId":7,"APMUserName":"DWDWD DSDAWDASDASD"}
       ,{"APMUserId":8,"APMUserName":"EWRWER EWRWER"}
       ,{"APMUserId":9,"APMUserName":"tert rtert"}
       ,{"APMUserId":11,"APMUserName":"vsfvd fgdfgdfhyrhr"}]
       ,"CCUserObj":[]
       ,"VoaUserObj":[]
    };
    $(obj.APMUserObj).each(function(){
        console.log(this.APMUserName);
    });

http://jsfiddle.net/tvww03a8/