JSON在线解析

所属目录
点击了解高性能代码运行API
运行结果
教程手册
代码仓库
极速运行
终端运行
图形+终端

                        
以下是用户最新保存的代码
其二同意无色大润发通过 发布于:2024-10-21 13:12 NBTK SGR0201 发布于:2024-08-21 10:55 广西田东PVM0101 发布于:2024-08-08 17:41 鲁花共享运营报告 发布于:2024-05-11 17:19 **全国地表水水质监测系统 断面点位数据集** 发布于:2024-03-02 18:33 AliRedPacket首页红包 发布于:2023-12-23 15:41 main主程序 发布于:2023-12-23 15:18 扬秋OL(autojs) 发布于:2023-12-23 15:43 json教师各项分数 发布于:2023-12-09 16:39 员工工作量 发布于:2023-11-07 15:17 浪潮POST 发布于:2023-10-30 11:22 报账单信息 发布于:2023-10-20 14:32 我带会员单位岁啊哈幅度缺乏撒网缺乏v 发布于:2022-09-27 08:28 环保token 发布于:2022-05-12 21:12 流水线的保存的json数据,把里面所有的job的几个信息摘出来,取出每个job的jobName、jobType、categoryId、realJob 内容。 发布于:2022-04-22 19:17 爱上CAD 发布于:2022-02-17 23:03 中国省市区 json 发布于:2021-10-15 13:39 供应商带出币种 发布于:2021-07-23 10:19 拉取采购收货 发布于:2021-07-13 16:14 解析IP地址 发布于:2021-04-12 20:45 OA --> CMDB_DCOS的北向数据 发布于:2021-02-02 15:00 测试json 是否正确 发布于:2021-01-13 11:06 python题库 发布于:2021-01-06 10:31 json 解析 发布于:2020-10-18 15:05 电池图所需数据 发布于:2020-10-08 18:32 电池图所需数据 发布于:2020-09-20 13:57 电池图所需数据 发布于:2020-09-20 13:57 JSON在线解析,JSON格式化 发布于:2020-09-16 12:10 电池图所需数据 发布于:2020-09-02 11:35 电池图所需数据 发布于:2020-08-25 17:50 建立一个mock测试 json 数据。 发布于:2020-08-22 10:32 地理缩写对照 发布于:2020-07-08 13:28 v2ray-config 发布于:2021-05-11 13:03 JSON在线解析,JSON格式化 发布于:2020-06-20 15:04 [更多]
显示目录

Jquery 遍历 Json 的实现代码



学习嵌入式的绝佳套件,esp8266开源小电视成品,比自己去买开发板+屏幕还要便宜,省去了焊接不当搞坏的风险。 蜂鸣版+触控升级仅36元,更强的硬件、价格全网最低。

点击购买 固件广场

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;
}

综合实例:

var array = {
    "a": "abc",
    "b": [1, 2, 3, 4, 5, 6],
    "c": 3,
    "d": {
        "name": "james",
        "age": 28
    },
    "e": null,
    "f": true
};
var arrayObj = {
    "a": {
        "name": "kobe",
        "age": 34
    },
    "b": {
        "name": "lofo",
        "age": 28
    }
};
//遍历array方式1
for (var x in array) {
    if (typeof array[x] == 'object' && array[x] != null) {
        for (var y in array[x]) {
            alert("key = " + y + " value = " + array[x][y]);
        }
    } else {
        alert("key = " + x + " value = " + array[x]); // 非array object
    }
}
//遍历array方式2
$.each(array, function(k, v) {
    var a = typeof(v);
    //数组与对象为object类型,其他分别是string与number类型
    //此时的k代表a、b、c、d,v代表对应的值
    if (typeof(v) == "object") {
        //获取数组与对象后,再去遍历这个数组与对象
        $.each(v, function(k1, v1) {
            window.alert("key = " + k1 + " value=" + v1);
        });
    } else {
        window.alert("key = " + k + " value=" + v);
    }
});
//遍历arrayObj方式1
for (var x in arrayObj) {
    for (var key in arrayObj[x]) {
        window.alert("key=" + key + " value=" + arrayObj[x][key]);
    }
}
//遍历arrayObj方式2
$.each(arrayObj, function(key, value) {
    $.each(value, function(k, v) {
        window.alert("key=" + k + " value=" + v);
    });
});
//遍历arrayObj方式3
$.each(arrayObj, function(key, value) {
    window.alert("key=" + key + " valueName=" + value.name + " valueAge=" + value.age);
});
var UserList = [
    { "UserID": 11, "Name": { "FirstName": "Truly", "LastName": "Zhu" }, "Email": "" },
    { "UserID": 12, "Name": { "FirstName": "Jeffrey", "LastName": "Richter" }, "Email": "" },
    { "UserID": 13, "Name": { "FirstName": "Scott", "LastName": "Gu" }, "Email": "" }
]
$.each(UserList, function(k, v) {
    $.each(v, function(k1, v1) {
        if (typeof(v1) == "object") {
            $.each(v1, function(k2, v2) {
                window.alert("key=" + k2 + " value=" + v2);
            });
        } else {
            window.alert("key=" + k1 + " value=" + v1);
        }
    });
});

var userArray = [
    { "UserID": 11, "Name": { "FirstName": "Truly", "LastName": "Zhu" }, "Email": "" },
    { "UserID": 12, "Name": { "FirstName": "Jeffrey", "LastName": "Richter" }, "Email": "" },
    { "UserID": 13, "Name": { "FirstName": "Scott", "LastName": "Gu" }, "Email": "" }
];
for (var i in userArray) {
    for (var k in userArray[i]) {
        if (typeof userArray[i][k] == "object" && userArray[i][k] != null) {
            for (var j in userArray[i][k]) {
                window.alert("key=" + j + "--value=" + userArray[i][k][j]);
            }
        } else {
            window.alert("key=" + k + "--value=" + userArray[i][k]);
        }
    }
}
由JSRUN为你提供的JSON在线运行、在线编译工具
        JSRUN提供的JSON 在线运行,JSON 在线运行工具,基于linux操作系统环境提供线上编译和线上运行,具有运行快速,运行结果与常用开发、生产环境保持一致的特点。
yout