<!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. Logstash 学习资料

    学习资料 网址 Logstash Reference(官方) https://www.elastic.co/guide/en/logstash/current/introduction.html

  2. 2019徐州网络赛H :function (min25筛)

    题意:f(i)=i的幂次之和. 求(N+1-i)*f(i)之和. 思路:可以推论得对于一个素数p^k,其贡献是ans=(N+1)[N/(P^k)]+P^k(1+2+3...N/(P^k)); 我们分两 ...

  3. redisTemplate 键值序列化策略

    redisTemplate 键值序列化策略 RedisSerializer<T> StringRedisSerializer JdkSerializationRedisSerializer ...

  4. vue大文件上传插件选哪个好?

    文件夹数据库处理逻辑 public class DbFolder { JSONObject root; public DbFolder() { this.root = new JSONObject() ...

  5. Pandas | 24 常用图形绘制

    基本绘图:绘图 Series和DataFrame上的这个功能只是使用matplotlib库的plot()方法的简单包装实现. import pandas as pd import numpy as n ...

  6. PHP读取文件内容的五种方式

    -----第一种方法-----fread()-------- <?php $file_path = "test.txt"; if(file_exists($file_path ...

  7. Python基于tkinter.messagebox实现简易消息框、对话框

    库导入: import tkinter import tkinter.messagebox 有关提示框: tkinter.messagebox.showinfo(title=None, message ...

  8. 百度前端技术学院task13源代码

    突然发现只看书不练习也是不行的,这么简单的我竟然都不会写了. 要注意innerHTML,innerText和outText之间的异同. 同时也要会使用DOM2的添加事件,移除事件等 <!DOCT ...

  9. Java的内存需要划分成为5个部分:

    Java的内存需要划分成为5个部分: 1.栈(Stack):存放的都是方法中的局部变量.方法的运行一定要在栈当中运行. 局部变量:方法的参数,或者是方法{}内部的变量 作用域:一旦超出作用域,立从栈内 ...

  10. 部署CentOS虚拟机集群

    1.在虚拟机中安装CentOS (1)使用CentOS-6.5-i386-minimal.iso.(2)创建虚拟机:打开Virtual Box,点击“新建”按钮,点击“下一步”,输入虚拟机名称为esh ...