Javascript Jquery 遍历Json的实现代码
更新时间:2010年03月31日 23:12:04 作者:
Javascript Jquery 遍历Json的实现代码,需要的朋友可以参考下。
复制代码 代码如下:
/*
author: liulf
function:
var __db_cpcj=vCpcj;
var __db_cp=vCp;
var vCp={"cppage":[
{"cpdh":"A01000101","page":"1","ca":"1309-36-0","mc":"硫铁矿","ename":"Pyrite","bm":"黄铁矿"},
{"cpdh":"A01000201","page":"1","ca":"1309-36-0","mc":"硫精砂","ename":"Pyrite concentrate;Sulfur concentrate","bm":""},
{"cpdh":"A01000202","page":"1","ca":"1309-36-0","mc":"硫精矿粉","ename":
"Powdered pyrite concentrate;Pyrites concentrate,powder;Sulfur concentrate,powder","bm":"硫精矿"},
{"cpdh":"A02000101","page":"1","ca":"","mc":"磷矿石","ename":"Phosphorus ore","bm":""},
{"cpdh":"A02000111","page":"2","ca":"","mc":"磷矿砂","ename":"Phosphorite grit","bm":""},
{"cpdh":"A02000201","page":"2","ca":"","mc":"磷矿粉","ename":"Phosphate rock powder","bm":""},
{"cpdh":"A03000101","page":"2","ca":"12447-04-0","mc":"硼矿石","ename":"Ascharite;Boric ore","bm":"硼镁矿"},
{"cpdh":"A04000101","page":"2","ca":"","mc":"钾长石","ename":"Potash feldspar;Potassium feldspars","bm":""},
{"cpdh":"A04000201","page":"2","ca":"12003-63-3","mc":"长石粉","ename":"Feldspar powder","bm":""},
{"cpdh":"A04000301","page":"2","ca":"","mc":"光卤石","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
如何遍历jsonc对象?其实方法很简单。
比如有如下json对象:
var obj ={”name”:”冯娟”,”password”:”123456″,”department”:”技术部”,”sex”:”女”,”old”:30};
遍历方法:
复制代码 代码如下:
for(var p in obj)
{
str = str+obj[p]+',';
return str;
}
您可能感兴趣的文章:
- JQuery遍历json数组的3种方法
- jQuery 遍历json数组的实现代码
- jquery动态遍历Json对象的属性和值的方法
- jquery遍历json对象集合详解
- jQuery遍历json中多个map的方法
- jQuery使用$.each遍历json数组的简单实现方法
- jQuery通过ajax请求php遍历json数组到table中的代码(推荐)
- jQuery筛选数组之grep、each、inArray、map的用法及遍历json对象
- jQuery遍历json的方法分析
- JS遍历JSON数组及获取JSON数组长度操作示例【测试可用】
- js遍历json的key和value的实例
- JS 遍历 json 和 JQuery 遍历json操作完整示例
相关文章
JS中JSON.parse(JSON.stringify())实现深拷贝
深拷贝就是完全拷贝一份新的对象,本文主要介绍了JS中JSON.parse(JSON.stringify())实现深拷贝,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2023-08-08浅谈JsonObject中的key-value数据解析排序问题
下面小编就为大家分享一篇浅谈JsonObject中的key-value数据解析排序问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2017-12-12
最新评论