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:
Related articles
- Jquery method for dynamically traversing properties and values of Json object
- Detailed jQuery traverse json object collection
- Method for traversing multiple maps in json
- Simple implementation of jQuery using $each to traverse json array
- jQuery request php to traverse json array to table code via ajax (recommended)
- jQuery filter array usage of grep, each, inArray, map and traverse json objects
- Analysis of jQuery traversal json method
- Js traversing instances of key and value in json
- JS traversal json and JQuery traversal json operation complete example
Trends