Home > Web Front-end > JS Tutorial > Javascript Jquery traverses Json implementation code_json

Javascript Jquery traverses Json implementation code_json

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 18:31:00
Original
1131 people have browsed it
Copy code The code is as follows:

/*
author: liulf
function:
var __db_cpcj=vCpcj;
var __db_cp=vCp;
var vCp={"cppage":[
{"cpdh":"A01000101","page":"1","ca": "1309-36-0","mc":"Pyrite","ename":"Pyrite","bm":"Pyrite"},
{"cpdh":"A01000201"," page":"1","ca":"1309-36-0","mc":"Sulfur concentrate","ename":"Pyrite concentrate;Sulfur concentrate","bm":""},
{"cpdh":"A01000202","page":"1","ca":"1309-36-0","mc":"Sulfur Concentrate Powder","ename":
" Powdered pyrite concentrate;Pyrites concentrate,powder;Sulfur concentrate,powder","bm":"Sulfur concentrate"},
{"cpdh":"A02000101","page":"1","ca": "","mc":"Phosphorus ore","ename":"Phosphorus ore","bm":""},
{"cpdh":"A02000111","page":"2", "ca":"","mc":"Phosphorite grit","ename":"Phosphorite grit","bm":""},
{"cpdh":"A02000201","page": "2","ca":"","mc":"Phosphate rock powder","ename":"Phosphate rock powder","bm":""},
{"cpdh":"A03000101" ,"page":"2","ca":"12447-04-0","mc":"Boron ore","ename":"Ascharite;Boric ore","bm":"Boron ore" },
{"cpdh":"A04000101","page":"2","ca":"","mc":"Potassium feldspar","ename":"Potash feldspar;Potassium feldspars" ,"bm":""},
{"cpdh":"A04000201","page":"2","ca":"12003-63-3","mc":"feldspar powder", "ename":"Feldspar powder","bm":""},
{"cpdh":"A04000301","page":"2","ca":"","mc":"光Halite","ename":"Carnallite","bm":""}
]}
*/
function ObjSearch()
{
this.kw = '';
this.searchCpcj= function()
{
$(vCpcj).each(function(){
});
}
this.searchCp = function()
{
// var json = eval(vCp.cppage)
// for(var i=0; i// {
// alert(json [i].cpdh " " json[i].page)
// break;
// }
$.each(vCp.cppage,function(index,content){
document. write('
' content.cpdh '

');
});
}
}

js
How to traverse jsonc objects? In fact, the method is very simple.
For example, there is the following json object:
var obj ={"name":"Feng Juan","password":"123456″,"department":"Technical Department","sex":"Female", "old":30};
Traversal method:
Copy code The code is as follows:

for(var p in obj)
{
str = str obj[p] ',';
return str;
}
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template