<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding:0;
        }
        .all{
            width:100%;
            height:800px;
        }
        .left{
            width:47%;
            height:800px;
            float: left;
            overflow: scroll;
            border:1px solid red;
        }
        .right{
            width:47%;
            height:800px;
            float: left;
            overflow: scroll;
            border:1px solid green;
        }
        #left-text{
            width:97%;
            height: 100%;
            padding: 10px 10px 10px 30px;
            border: 0;
            border-right: solid 1px #E5EBEE;
            border-bottom: solid 1px #eee;
            border-radius: 0;
            resize: none;
            outline: none;
        }
        #right-text{
            margin:20px;
        }
        .right button{
        width: 200px;
        float: left;
        margin: 10px 30px;
        height: 30px;
        cursor: pointer;
        }
        #right-text{
            display: inline-block;
            color:#ff7799;
            font-size: 19px;
        }
        .two{
            display: inline-block;
            color:#9977ff;
        }
        .three{
            display: inline-block;
            color:green;
        }
        .four{
            display: inline-block;
            color:#000;
        }
    </style>
</head>
<body>
<div class="all">
    <div class="left">
        <textarea name="" id="left-text" cols="30" rows="10"></textarea>
    </div>
    <div class="right">
        <button class="right22">输出文字</button>
        <div  id="right-text">
        </div>
    </div>
</div>
<script src="jquery-1.10.2.js"></script>
<script>
    $(function(){
        $(".right22").click(function(){
        var str=$("#left-text").val();
        var dataJson1 =$.parseJSON(str)
        var dataXIU=dataJson1.service_config.config;
            for (var index in dataXIU){
                 $("#right-text").append("<span class='one'>一级类别:<b>"+dataXIU[index].category_alias+"</b></span></br>");
            // console.log(dataXIU[index].goodsCategory);
               for (var indexs in dataXIU[index].goodsCategory){
                   var name=dataXIU[index].goodsCategory[indexs].goods_category_name;
                   var dan=dataXIU[index].goodsCategory[indexs].goods_unit
                    $("#right-text").append("<span class='two'>二级类别:<b>"+name+"</b></span></br>");
                        // console.log(dataXIU[index].goodsCategory[indexs].son);
                        var sanji=dataXIU[index].goodsCategory[indexs].son;
                        for (var indexss in sanji){
                            var sanname=sanji[indexss].goods_category_name;
                            var sandan=sanji[indexss].goods_unit
                            $("#right-text").append("<span class='three'>三级类别:<b>"+sanname+"</b>  单位="+sandan+"</span></br>");
                            // console.log(sanji[indexss].attr);    
                                            for (var indexsss in sanji[indexss].attr){
                                                var siname=sanji[indexss].attr[indexsss].field_alias;
                                                var sidan=sanji[indexss].attr[indexsss].enum;
                                                 console.log(sidan)
                                                 
                                                if(sidan!=undefined){
                                                    for(indexssss in sidan ){
                                                        var alias= sidan[indexssss].alias;
                                                        var wudan= sidan[indexssss].value;
                                                        $("#right-text").append("<span class='four'>四级:"+siname+"-<b>"+wudan+"</b></span></br>");
                                                        
                                                    }
                                                    
                                                }
                                                                
                                             }
                         }
              }
          }
        })
    })
</script>
</body>
</html>

91.用js遍历原生json数据的更多相关文章

  1. js循环读取json数据,将读取到的数据用js写成表格

    ①js循环读取json数据的方式: var data=[{"uid":"2688","uname":"*江苏省南菁高级中学 022 ...

  2. Js循环读取JSON数据

    <script> $(function () { var jsonString = '{Unid:"1",CustomerName:"宋江",Age ...

  3. js实现对json数据的序列化(兼容ie6以上浏览器)

    /** * 增加对JSON数据的序列化方法, * 主要用于IE6.7不支持JSON对象的浏览器 */ var xue = xue || {};xue.json = xue.json || {}; xu ...

  4. js读取解析JSON数据

    JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式.同时,JSON是 JavaScript 原生格式,这意 ...

  5. js之操作JSON数据

    JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式.同时,JSON是 JavaScript 原生格式,这意 ...

  6. js读取解析JSON数据(转)

    JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式.同时,JSON是 JavaScript 原生格式,这意 ...

  7. 菜鸟笔记:node.js+mysql中将JSON数据构建为树(递归制作树状菜单数据接口)

    初学Web端开发,今天是第一次将所学做随笔记录,肯定存在多处欠妥,望大家海涵:若有不足,望大家批评指正. 进实验室后分配到的第一个项目,需要制作一个不确定层级树形菜单的数据接口,对于从来没实战编过程的 ...

  8. 在java中像js那样处理json数据

    工作中经常需要通过ajax向前台返回json数据,都是通过拼字符串拼出来的,很发麻烦不说,还容易出错. 于是想,能不能像js那样操作json呢?或者说更方便的操作呢? Google的gson就是这样的 ...

  9. json-server 和mock.js生成大量json数据

    JSON-server和mock.jsmock文件夹下 db.json db.jsjson-sever使用 安装:npm install json-server -g/mock 目录下执行json-s ...

随机推荐

  1. bootstrap ui样例

    http://demo.codedefault.com/demo/ui/theadmin/samples/invoicer/settings.html

  2. IComparable<T>.CompareTo(T) 方法

    IComparable<T>.CompareTo(T) 方法 定义 命名空间: System 程序集: System.Runtime.dll, mscorlib.dll, netstand ...

  3. uniform

    float timeValue = glfwGetTime(); float greenValue = (sin(timeValue) / 2.0f) + 0.5f; int vertexColorL ...

  4. 在Hadoop-3.1.2上安装HBase-2.2.1

    目录 目录 1 1. 前言 3 2. 缩略语 3 3. 安装规划 3 3.1. 用户规划 3 3.2. 目录规划 4 4. 相关端口 4 5. 下载安装包 4 6. 修改配置文件 5 6.1. 修改策 ...

  5. 洛谷p1747好奇怪的游戏题解

    题目 永远不要怀疑劳动人民的智慧! 把快读里最后的return直接返回零的 我已经不是第一次写错了! 我要是再写错我就****** 主要是逆向思维,把从两个点往(1, 1)走想成从(1, 1)点往这两 ...

  6. iptables 的几个状态

    iptables的状态跟踪连接有4种,分别是:NEW.ESTABLISHED.RELATED.INVALID,除了从本机出去的数据包有NAT表的OUTPUT链处理外,其它所有的状态跟踪都在NAT表中的 ...

  7. 20165214 2018-2019-2 《网络对抗技术》Exp9 Web安全基础 Week13

    <网络对抗技术>Exp9 Web安全基础 Week13 一.实验目标与内容 1.实践内容 (1).本实践的目标理解常用网络攻击技术的基本原理,做不少于7个题目.包括(SQL,XSS,CSR ...

  8. 微信小程序云开发不完全指北

    微信小程序云开发不完全指北 首先必须说明云开发的"云"并不是类似云玩家里的云的意思,而是微信小程序真的提供了云开发的接口以及一个简单的提供存储.数据库服务的虚拟后台(对于一些轻量小 ...

  9. Linux上使用yum安装openjdk

    来源:https://www.cnblogs.com/yaun1498078591/p/10368884.html 使用yum查找jdk: yum search java|grep jdk # yum ...

  10. laravel代码规范强制检查

    目录 介绍 代码规范检查与修复 在git commit时自动检查代码规范 后记 介绍 在团队协作开发中,代码规范是必要的.以前的规范都是自己定,然后手动检查,很难做到有效的约束. 现代的PHP,则有得 ...