javascript - js如何循环这样的json数据
巴扎黑
巴扎黑 2017-04-10 15:23:53
0
4
362
{
  "data": {
    "json1": [
      {
        "time": "05-17",
        "msg": 0
      },
      {
        "time": "05-18",
        "msg": 2
      }
    ],
    "json2": [
      {
        "time": "05-17",
        "msg": 0
      },
      {
        "time": "05-18",
        "msg": 2
      }
    ],
    "json3": [
      {
        "time": "05-17",
        "msg": 0
      },
      {
        "time": "05-18",
        "msg": 2
      }
    ]
  }
}

请教下这样的数据如何循环
巴扎黑
巴扎黑

reply all(4)
Peter_Zhu
php$.each(arr.data,function(i,v){

    console.log(i,v);
})
PHPzhong
jsfunction each(data, fn){
  if(Object.prototype.toString.call(data) == '[object Array]'){
    var l = data.length, i = 0;
    for(var i = 0, l = data.length; i < l; i++){
      each(data[i], fn);
    }
  }
  else if(Object.prototype.toString.call(data) == '[object Object]'){
    for(var prop in data){
      each(data[prop], fn);
    }
  }
  else {
    fn(data);
  }
}

each(data, function(d){
  console.log(d);
})
阿神
for (var i in DATA)
Ty80
javascriptfor(var i in json.data){
    var arr = json.data[i];
    if(arr.length){
        for(var j=0;j<arr.length;j++){
            // console.log(arr[j])  {time:"05-17",msg:2}
        }
    }
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template