日期:2014-05-16  浏览次数:20335 次

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)   
  }   
}