当前位置: 代码迷 >> JavaScript >> js循环array,json,地图
  详细解决方案

js循环array,json,地图

热度:187   发布时间:2012-11-23 00:03:43.0
js循环array,json,map
var str = '[{"uname":"王强","day":"2010/06/17"},{"uname":"王海云","day":"2010/06/11"}]';  

for(var i=0;i<jsonList.length;i++){ 


     for(var key in jsonList[i]){

           alert("key:"+key+",value:"+jsonList[i][key]); 

        } 

   }



var mapColumn = {
             "vdoing" : "访问深度",
             "_visitorNumber": "访问量",
             "_pageViews": "浏览量",
             "_jumpOutRate": "跳出率",
             "_avgAccessTime": "平均访问时长",
             "_allTargetConvRate": "转化率",
             "_orderTotalPrice": "总收益"
        
         };
 var target=[];
 for (var key in mapColumn) {
             target.push(key);
         }


.function text(){   
  var json = {"options":"[{\"text\":\"王家湾\",\"value\":\"9\"},{\"text\":\"李家湾\",\"value\":\"10\"},{\"text\":\"邵家湾\",\"value\":\"13\"}]"}    
 json = eval(json.options)   
 for(var i=0; i<json.length; i++)   
  {   
     alert(json[i].text+" " + json[i].value)   
  }   
}  
  相关解决方案