json是前后端数据交互的关键。后端提供的接口中的数据几乎都是通过json来表现的,所以,需要对这个json做一些小结;

  这里要推进谷歌的插件Fehelp前端助手,这个可以清楚的看到json的数据;

  以如下json数据为例

{
"equipments": [
{
"run_status": "1",
"name": "空压机1",
"data": {
"id": "4028817a5c8a9943015caa447ac727f0",
"equipment_id": 1,
"a_electricity": 113,
"shake": 2.5,
"rate": 0,
"temperature1": 66,
"temperature2": 77,
"pressure1": 0,
"pressure2": -13.9,
"pressure3": 0.31,
"air_supply_pressure": 0.31,
"venting_temperature": 77,
"run_time": 15629,
"load_time": 14750,
"main_a_electricity": 0,
"run_status1": "100000000011",
"run_status2": "0",
"control_status": 0,
"oil_filter_used_time": 2941,
"oil_distributor_used_time": 0,
"air_filter_used_time": 0,
"lubricating_oil_used_time": 2941,
"lubricating_grease_used_time": 2941,
"degree": 269208,
"inverter_fault_code": 0,
"remark2": null,
"remark1": 0,
"power": 71,
"link_status": 1,
"date": 1497505233603,
"hour": 2017061513,
"day": 20170615,
"month": 201706,
"year": 2017
},
"load_status": "1",
"link_status": 1,
"fault": null,
"type": 4,
"equipment_id": 1
},
{
"run_status": "1",
"name": "空压机2",
"data": {
"id": "4028817a5c8a9943015caa447ac827f1",
"equipment_id": 2,
"a_electricity": 115,
"shake": 2.1,
"rate": 88.6,
"temperature1": 62,
"temperature2": 77,
"pressure1": 0.428,
"pressure2": -10.1,
"pressure3": 0.4,
"air_supply_pressure": 0.4,
"venting_temperature": 77,
"run_time": 16060,
"load_time": 15996,
"main_a_electricity": 143,
"run_status1": "100000000011",
"run_status2": "0",
"control_status": 0,
"oil_filter_used_time": 2997,
"oil_distributor_used_time": 312,
"air_filter_used_time": 88,
"lubricating_oil_used_time": 2997,
"lubricating_grease_used_time": 2997,
"degree": 200835,
"inverter_fault_code": 13,
"remark2": null,
"remark1": 0,
"power": 72,
"link_status": 1,
"date": 1497505233603,
"hour": 2017061513,
"day": 20170615,
"month": 201706,
"year": 2017
},
"load_status": "1",
"link_status": 1,
"fault": {
"id": "4028817a5c8a9943015c948cd2734d2f",
"type": 1,
"has_read": null,
"date": "2017-06-11 08:27:55",
"equipment_id": 2,
"info": "空压机2:[报警]"
},
"type": 4,
"equipment_id": 2
},
{
"run_status": "1",
"name": "空压机3",
"data": {
"id": "4028817a5c8a9943015caa447ac927f2",
"equipment_id": 3,
"a_electricity": 70,
"shake": 0.6,
"rate": 17.8,
"temperature1": 38,
"temperature2": 78,
"pressure1": 0.32,
"pressure2": -2.6,
"pressure3": 0.308,
"air_supply_pressure": 0.308,
"venting_temperature": 78,
"run_time": 6751,
"load_time": 6733,
"main_a_electricity": 174,
"run_status1": "11",
"run_status2": "0",
"control_status": 0,
"oil_filter_used_time": 0,
"oil_distributor_used_time": 137,
"air_filter_used_time": 775,
"lubricating_oil_used_time": 0,
"lubricating_grease_used_time": 0,
"degree": 376393,
"inverter_fault_code": -23017,
"remark2": null,
"remark1": 0,
"power": 43,
"link_status": 1,
"date": 1497505233603,
"hour": 2017061513,
"day": 20170615,
"month": 201706,
"year": 2017
},
"load_status": "1",
"link_status": 1,
"fault": {
"id": "4028817a5ba84088015bb2f9496059a7",
"type": 1,
"has_read": null,
"date": "2017-04-28 13:12:13",
"equipment_id": 3,
"info": "空压机3:[主电机电流故障, 报警]"
},
"type": 4,
"equipment_id": 3
},
{
"run_status": "1",
"name": "空压机4",
"data": {
"id": "4028817a5c8a9943015caa447acb27f3",
"equipment_id": 4,
"a_electricity": 68,
"shake": 2.5,
"rate": 44.8,
"temperature1": 66,
"temperature2": 68,
"pressure1": 0.429,
"pressure2": -4.1,
"pressure3": 0.41,
"air_supply_pressure": 0.41,
"venting_temperature": 68,
"run_time": 16551,
"load_time": 16542,
"main_a_electricity": 120,
"run_status1": "100000000011",
"run_status2": "0",
"control_status": 0,
"oil_filter_used_time": 3065,
"oil_distributor_used_time": 182,
"air_filter_used_time": 100,
"lubricating_oil_used_time": 3065,
"lubricating_grease_used_time": 3065,
"degree": 186991,
"inverter_fault_code": 22,
"remark2": null,
"remark1": 0,
"power": 38,
"link_status": 1,
"date": 1497505233603,
"hour": 2017061513,
"day": 20170615,
"month": 201706,
"year": 2017
},
"load_status": "1",
"link_status": 1,
"fault": null,
"type": 4,
"equipment_id": 4
},
{
"run_status": "0",
"name": "空压机5",
"data": {
"id": "4028817a5c8a9943015caa447acc27f4",
"equipment_id": 5,
"a_electricity": 0,
"shake": 0,
"rate": 0,
"temperature1": 0,
"temperature2": 0,
"pressure1": 0.409,
"pressure2": -100,
"pressure3": 0,
"air_supply_pressure": 0,
"venting_temperature": 0,
"run_time": 601,
"load_time": 0,
"main_a_electricity": 0,
"run_status1": "0",
"run_status2": "0",
"control_status": 0,
"oil_filter_used_time": 601,
"oil_distributor_used_time": 601,
"air_filter_used_time": 601,
"lubricating_oil_used_time": 601,
"lubricating_grease_used_time": 601,
"degree": 0,
"inverter_fault_code": 0,
"remark2": null,
"remark1": 0,
"power": 0,
"link_status": 1,
"date": 1497505233603,
"hour": 2017061513,
"day": 20170615,
"month": 201706,
"year": 2017
},
"load_status": "0",
"link_status": 1,
"fault": null,
"type": 4,
"equipment_id": 5
},
{
"name": "冷干机1",
"data": {
"id": 4852493,
"equipment_id": 6,
"m0": 50,
"m1": 6.4,
"m2": 135,
"m3": 150,
"m4": 20,
"m5": 2,
"m6": 1,
"m7": 0,
"m8": 0,
"m9": 0,
"m10": 0,
"m11": 13.37,
"m12": 0,
"m13": 0,
"m14": 0,
"m15": 0,
"m16": 0,
"m17": 0,
"m18": 0,
"m19": 15,
"m20": 0,
"m21": 0,
"power": 3,
"degree": 10840,
"electricity": 6,
"link_status": 1,
"date": 1497505233603,
"hour": 2017061513,
"day": 20170615,
"month": 201706,
"year": 2017
},
"fault": null,
"type": 6,
"equipment_id": 6
},
{
"name": "冷干机2",
"data": {
"id": 4852494,
"equipment_id": 7,
"m0": 40,
"m1": 15.1,
"m2": 135,
"m3": 189,
"m4": 20,
"m5": 2,
"m6": 1,
"m7": 0,
"m8": 0,
"m9": 0,
"m10": 0,
"m11": 12.4,
"m12": 0,
"m13": 0,
"m14": 0,
"m15": 0,
"m16": 0,
"m17": 0.297,
"m18": 0,
"m19": 20,
"m20": 0,
"m21": 0,
"power": 3,
"degree": 17258,
"electricity": 11,
"link_status": 1,
"date": 1497505233603,
"hour": 2017061513,
"day": 20170615,
"month": 201706,
"year": 2017
},
"fault": null,
"type": 6,
"equipment_id": 7
},
{
"name": "流量计1",
"data": {
"id": "4028817a5c8a9943015caa447acd27f5",
"equipment_id": 8,
"dew_point": -20,
"real_time_flow": 1286,
"workshop_pressure": 0.423,
"flow": 10772462,
"iquid_level1": 0,
"iquid_level2": 0,
"iquid_level3": 0,
"iquid_level4": 0,
"il_status": 0,
"il_alert": 0,
"link_status": 1,
"date": 1497505233603,
"hour": 2017061513,
"day": 20170615,
"month": 201706,
"year": 2017
},
"fault": null,
"type": 11,
"equipment_id": 8
},
{
"name": "流量计2",
"data": {
"id": "4028817a5c8a9943015caa447ace27f6",
"equipment_id": 9,
"dew_point": -20,
"real_time_flow": 1315,
"workshop_pressure": 0.304,
"flow": 12162422,
"iquid_level1": 0,
"iquid_level2": 0,
"iquid_level3": 0,
"iquid_level4": 0,
"il_status": 0,
"il_alert": 0,
"link_status": 1,
"date": 1497505233603,
"hour": 2017061513,
"day": 20170615,
"month": 201706,
"year": 2017
},
"fault": null,
"type": 11,
"equipment_id": 9
},
{
"name": "联控箱",
"data": {
"id": 2426247,
"date": 1497505233603,
"jc_pressure": 0.31,
"jc_load_pressure": 0.001,
"jc_unload_pressure": 0.001,
"jc_rate": 0,
"jc_status": 0,
"link_status": "1111100000",
"run_status": "11110",
"load_status": "11110",
"hour": 2017061513,
"day": 20170615,
"month": 201706,
"year": 2017,
"equipment_id": 10,
"electricity": 366
},
"fault": null,
"type": 12,
"equipment_id": 10
}
],
"rooms": [
{
"bgl": 9.02,
"name": "空压机房",
"data": {
"id": "4028817a5c8a9943015caa447ad427f9",
"room_id": 1,
"degree": 1061525,
"electricity": 383,
"power": 230,
"flow": 22934884,
"real_time_flow": 2601,
"date": 1497505233603,
"hour": 2017061513,
"day": 20170615,
"month": 201706,
"year": 2017,
"temperature": null,
"humidity": null
}
},
{
"bgl": 0,
"name": "01号配电房",
"data": null
},
{
"bgl": 0,
"name": "02号配电房",
"data": null
}
]
}

  这个json数据中包含equipments和rooms两个数组,ajax接受这个json数据之后需要通过JSON.parse方法转换为对象,这样就能访问里面的数据了。然后JSON.parse(data).equipments['i']便可以访问数组里面的数据了。这个数字里面又是对象,可以继续通过'.'语法调用里面的数据;

浏览器端一般情况下,我们可以使用 JSON.parse() 方法将json数据转换为 JavaScript 对象来渲染数据到页面上;

服务器端我们通常可通过JSON.stringify(obj)将对象装换为字符串来使用

关于json对象的使用小结!的更多相关文章

  1. js学习-自定义函数、对象的字面量、json对象学习小结

    一.自定义对象的构造: var student=new Object(); //object是顶级对象,使用构造函数的方法创建一个对象,此处的意思是创建了一个学生的空对象 student.name=& ...

  2. java后台常用json解析工具问题小结

    若排版紊乱可查看我的个人博客原文地址 java后台常用json解析工具问题小结 这里不细究造成这些问题的底层原因,只是单纯的描述我碰到的问题及对应的解决方法 jackson将java对象转json字符 ...

  3. 浅谈对Jquery+JSON+WebService的使用小结

    https://www.jb51.net/article/36207.htm  更新时间:2013年04月28日 12:19:55   作者:    我要评论   本篇文章介绍了对Jquery+JSO ...

  4. 一种简单,轻量,灵活的C#对象转Json对象的方案(续)

    本文参考资料 一种简单,轻量,灵活的C#对象转Json对象的方案 [源码]Literacy 快速反射读写对象属性,字段 一段废话 之前我已经介绍了这个方案的名称为JsonBuilder,这套方案最大的 ...

  5. jQuery中的$.extend方法来扩展JSON对象及合并,方便调用对象方法

    $.extend方法可以扩展JSON对象,用一个或多个其他对象来扩展一个对象,返回被扩展的对象. 例一 合并 settings 和 options,修改并返回 settings var setting ...

  6. Json对象与Json字符串互转(4种转换方式)

    Json字符与Json对象的相互转换方式有很多,接下来将为大家一一介绍下,感兴趣的朋友可以参考下哈,希望可以帮助到你 1>jQuery插件支持的转换方式: 复制代码代码如下: $.parseJS ...

  7. js压缩xml字符串,将xml字符串转换为xml对象,将xml对象转换为json对象

    /** * 压缩xml字符串 */ function compressXmlStr(str){ var prefix, suffix; var i = str.indexOf("\r&quo ...

  8. js中的json对象和字符串之间的转化

    字符串转对象(strJSON代表json字符串)   var obj = eval(strJSON);   var obj = strJSON.parseJSON();   var obj = JSO ...

  9. jQuery中json对象与json字符串互换

    json字符串转json对象:jQuery.parseJSON(jsonStr); json对象转json字符串:JSON.stringify(jsonObj); 根据“|”把字符串变成数组.spli ...

随机推荐

  1. 记录一次docker容器内修改my.cnf配置文件max_allowed_packet参数的过程

    1. 问题背景 在一次新版本功能开发完毕,配合测试的过程中,测试反馈某个XxlJob定时任务一直执行失败,在分析了日志之后,找到了报错的原因: Packet for query is too larg ...

  2. 30道关于linux的基础命令小题,先练练手

    1.修改主机名为yuanlai0224命令是: 2.切换⽬录到/yuchao01/data/,再创建脚本/my_website/scripts/start.sh. 绝对路径.相对路径两种写法 3.查看 ...

  3. LGP3790题解

    建议改为 省 选 原 题 题意:求所有生成树的边权 \(\gcd\) 之和. 看到 \(\gcd\) 立刻想反演. \[\sum_T\gcd_{e \in T}e_v \] 这里设 \(E=e_v(e ...

  4. 35个高级python知识点

    No.1 一切皆对象 众所周知,Java中强调"一切皆对象",但是Python中的面向对象比Java更加彻底,因为Python中的类(class)也是对象,函数(function) ...

  5. [WPF] 如何实现文字描边

    1. 前言 WPF 的 TextBlock 提供了大部分常用的文字修饰方法,在日常使用中基本够用.如果需要更丰富的表现方式,WPF 也提供了其它用起来复杂一些的工具去实现这些需求.例如这篇文章介绍的文 ...

  6. mysqkl修改存放位置 列的数据

    1.表一旦创建后,列的数据是否可以修改?如果可以说明语法 update 表名称 set 列名='新内容' where 列名=某值  橙色代表条件列 2.修改存放数据的文件夹 先关闭mysql  把da ...

  7. js 加载 xml 及遍历属性及内容 整理

    本文旨在: js加载xml文件并读取节点信息 1 加载xml文件 var xmlDoc = loadXMLDoc("negativeData.xml"); function loa ...

  8. 冒泡排序和鸡尾酒排序(code)

    昨天回顾了下冒泡排序和鸡尾酒排序,用面向对象的方式写了一下,并且优化了代码,记录一下~ 一.冒泡排序 # 冒泡排序 class BubbleSort(object): def __init__(sel ...

  9. 6月15日 python学习总结 Django模板语言相关内容

    Django模板语言相关内容   Django模板系统 官方文档 常用语法 只需要记两种特殊符号: {{  }}和 {% %} 变量相关的用{{}},逻辑相关的用{%%}. 变量 {{ 变量名 }} ...

  10. 面试官:Zookeeper是什么,它有什么特性与使用场景?

    哈喽!大家好,我是小奇,一位不靠谱的程序员 小奇打算以轻松幽默的对话方式来分享一些技术,如果你觉得通过小奇的文章学到了东西,那就给小奇一个赞吧 文章持续更新 一.前言 作为一名Java程序员,Zook ...