欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

本文實(shí)例講述了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){
    //解析單個(gè)任務(wù)參數(shù)
    jQuery.each(item ,function(key){
      alert(key);//key
            alert(item[key]);//value
          });
  });
}

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

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

在線JSON代碼檢驗(yàn)、檢驗(yàn)、美化、格式化工具:
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擴(kuò)展技巧總結(jié)》及《jquery選擇器用法總結(jié)

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

相關(guān)文章

最新評(píng)論