亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

jQuery解析json格式數(shù)據(jù)示例

 更新時間:2018年09月01日 12:08:22   作者:gundumw100  
這篇文章主要介紹了jQuery解析json格式數(shù)據(jù),涉及jQuery針對json格式數(shù)據(jù)元素遍歷相關(guān)操作技巧,需要的朋友可以參考下

本文實例講述了jQuery解析json格式數(shù)據(jù)。分享給大家供大家參考,具體如下:

var arr1 = [ "one", "two", "three", "four", "five" ];
$.each(arr1, function(){
  alert(this);
});

輸出:

one   two  three  four   five

var arr2 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
$.each(arr2, function(i, item){
  alert(item[0]);
});

輸出:

1   4   7

var obj = { one:1, two:2, three:3, four:4, five:5 };
$.each(obj, function(key, val) {
  alert(obj[key]);
});

輸出:

1   2  3  4  5

//json格式
var param = [{'subJobClass':'com.sample.quartz.MyJob','subJobMethod':'hello','taskParam':[{'username':'張三'},{'age':'28'},{'tel':'15818821129'}]}];
//設(shè)置參數(shù)值
if(param.length>0){
  alert(param[0].subJobClass);
  alert(param[0].subJobMethod);
  var taskParam = param[0].taskParam ;
  //遍歷任務(wù)參數(shù)數(shù)組
  jQuery.each(taskParam,function(i, item){
    //解析單個任務(wù)參數(shù)
    jQuery.each(item ,function(key){
      alert(key);//key
            alert(item[key]);//value
          });
  });
}

感興趣的朋友可以使用在線HTML/CSS/JavaScript代碼運行工具http://tools.jb51.net/code/HtmlJsRun測試上述代碼運行效果。

PS:關(guān)于json操作,這里再為大家推薦幾款比較實用的json在線工具供大家參考使用:

在線JSON代碼檢驗、檢驗、美化、格式化工具:
http://tools.jb51.net/code/json

JSON在線格式化工具:
http://tools.jb51.net/code/jsonformat

在線XML/JSON互相轉(zhuǎn)換工具:
http://tools.jb51.net/code/xmljson

json代碼在線格式化/美化/壓縮/編輯/轉(zhuǎn)換工具:
http://tools.jb51.net/code/jsoncodeformat

在線json壓縮/轉(zhuǎn)義工具:
http://tools.jb51.net/code/json_yasuo_trans

更多關(guān)于jQuery相關(guān)內(nèi)容還可查看本站專題:《jQuery操作json數(shù)據(jù)技巧匯總》、《jQuery常用插件及用法總結(jié)》、《jQuery擴展技巧總結(jié)》及《jquery選擇器用法總結(jié)

希望本文所述對大家jQuery程序設(shè)計有所幫助。

相關(guān)文章

最新評論