Copy Code code 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 fine Sand", "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 concentrates "},
{"CPDH": "A02000101", "page": "1", "Ca": "", "MC": "Phosphate Ore", "ename": "Phosphorus ore", "BM": ""},
{"CPDH": "A02000111", "page": "2", "Ca": "", "MC": "Phosphate Ore", "ename": "Phosphorite Grit", "BM": ""},
{"CPDH": "A02000201", "page": "2", "Ca": "", "MC": "Phosphate ore powder", "ename": "Phosphate Rock powder", "BM": ""},
{"CPDH": "A03000101", "page": "2", "Ca": "12447-04-0", "MC": "Boron ore", "ename": "Ascharite; Boric ore "," BM ":" Boron magnesium ore "},
{"CPDH": "A04000101", "page": "2", "Ca": "", "MC": "Potash 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": "Carnallite", "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<json.length; i++)
// {
Alert (json[i].cpdh+ "" + json[i].page)
Break
// }
$.each (Vcp.cppage,function (index,content) {
document.write (' <div> ' +content.cpdh+ ' </div><br/> ');
});
}
}
Js
How do I traverse the Jsonc object? In fact, the method is very simple.
For example, you have the following JSON object:
var obj ={"name": "Feng Juan", "Password": "123456″," "Department": "Technical department", "Sex": "female", "old": 30};
Traversal method:
Copy Code code as follows:
For (var p in obj)
{
str = str+obj[p]+ ', ';
return str;
}