//移除空白节点,空白节点的类型是3 function removeWhiteNode(node) { for (var i = 0; i < node.childNodes.length; i++) { if (node.childNodes[i].nodeType === 3 && /^\s+$/.test(node.childNodes[i].nodeValue)) { node.childNodes[i].parentNode.
一段json可能有很多的子节点,需要查询到某一个节点 用到的js是 find-in-json.js 地址是:https://gist.github.com/iwek/3924925 貌似翻|||墙才能看得到 我还是粘贴出来吧 find-in-json.js完整代码如下: //return an array of objects according to key, value, or key and value matching function getObjects(obj, key, val)
simplejson.errors.JSONDecodeError: Expecting value: line column () 提示说是解码错误 可以用下面的方法判断json文件是否为空 import json#读取 with open('tmp.json', 'r') as f: data = f.read() if(not bool(data)): print("json is empty!") 但是在非空情况下会报错!!! import json data ={"