Home>

First, use each to traverse

$(function () {
</p>
<p>
var tbody="";
 //------------ Traversal object. Use of each -------------
 //Object syntax json data format (When the server-side callback returns the object data format is json data format,Must guarantee json format requirements,The callback object must be converted using the eval function (otherwise the object will not be obtained). This article does not detail the data problems of server-side callbacks.
We will customize the object directly)
 var obj=[{"name":"item navy", "password":"123456"}];
 $("#result"). html ("------------ Traversal object. Use of each -------------");
 alert (obj);//is an object element
 //Next use each to traverse
 $.each (obj, function (n, value) {
 alert (n + "" + value);
 var trs="";
 trs +="&tr><td>" + value.name + "</td><td>" + value.password + "</td></tr>";
 tbody +=trs;
 });
</p>
<p>
$("#project"). append (tbody);
</p>
<p>
});

Second, jquery traversal parse json object 1:

var json=[{dd:"sb", aa:"Dongdong", re1:123}, {cccc:"dd", lk:"1qw"}];
for (var i=0, l=json.length;i<l;i ++) {
 for (var key in json [i]) {
 alert (key + ":" + json [i] [key]);
 }
}

Third, jquery traversal parse json objectTwo

There are the following json objects:

var obj={"name":"Feng Juan", "password":"123456", "department":"Technical Department", "sex":"Female", "old":30};

Traversal method:

for (var p in obj) {
 str=str + obj [p] + ",";
 return str;
}

PS:Here are some more useful json online tools for your reference:

Online json code inspection, inspection, beautification, formatting tools:

json online formatting tool:

Online xml/json conversion tool:

json code online formatting/beautifying/compressing/editing/converting tool:

Online json compression/escaping tool:

C language style/html/css/json code formatting and beautifying tool:

  • Previous Analysis of CSharpThinking extension method in aspnet
  • Next Method for judging the end of file reading in readline in python
  • Trends