可以用于通过路径解析JSON对象的一个函数
主页:
http://goessner.net/articles/JsonPath/
和XPath的使用对比
XPath JSONPath Description
/ $ the root object/element
. @ the current object/element
/ . or [] child operator
.. n/a parent operator
// .. recursive descent. JSONPath borrows this syntax from E4X.
* * wildcard. All objects/elements regardless their names.
@ n/a attribute access. JSON structures don't have attributes.
[] [] subscript operator. XPath uses it to iterate over element collections and for predicates. In Javascript and JSON it is the native array operator.
| [,] Union operator in XPath results in a combination of node sets. JSONPath allows alternate names or array indices as a set.
n/a [start:end:step] array slice operator borrowed from ES4.
[] ?() applies a filter (script) expression.
n/a () script expression, using the underlying script engine.
() n/a grouping in Xpath
{ "store": {
"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{ "category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{ "category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{ "category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
}
}
XPath JSONPath Result
/store/book/author $.store.book
.author the authors of all books in the store
//author $..author all authors
/store/* $.store.* all things in store, which are some books and a red bicycle.
/store//price $.store..price the price of everything in the store.
//book[3] $..book[2] the third book
//book[last()] $..book[(@.length-1)]
$..book[-1:] the last book in order.
//book[position()<3] $..book[0,1]
$..book[:2] the first two books
//book[isbn] $..book[?(@.isbn)] filter all books with isbn number
//book[price<10] $..book[?(@.price<10)] filter all books cheapier than 10
//* $..* all Elements in XML document. All members of JSON structure.
分享到:
相关推荐
1. 更换默认的xpath库 除了ie,其他主要浏览器都是内置对xpath的支持的,但ie不行,所以selenium 使用了javascript库,默认使用的是ajaxslt,这个会比较慢,可以换成 javascript-xpath, 虽然比firefox还是慢...
官方离线安装包,亲测可用
读json文件自动生成jsonpath,xpath也可以,改改就好
JsonPath:使用类似XPATH的语法从JSON提取数据
wicked-good-xpath, 纯JS实现DOM级别 3 XPath规范 很好的XPath Wicked XPath是谷歌编写的DOM级别 3 XPath规范的纯JavaScript实现。 它为每个浏览器中的HTML文档启用XPath评估。 我们相信它是JavaScript中最快的XPath...
jsonpath-ng:最后,一个旨在符合标准的Python JSONPath实现。 就这样。 好好享受
json-xpath:在JSON文档上提供XPath支持
测试的库是: 包裹NPM下载最后提交 映射过滤器减少 jsonpath-plus和jsonpath使用XPath for Json Specification 。 json-query具有自己的自定义DSL。 JSONStream , oboe和map-filter-reduce是流媒体库,尽管我在使...
离线安装包,亲测可用
节点红色贡献-json 一个强大的节点,用于处理 JSON 对象。 安装 从您的node-red目录: npm install node-red-contrib-json 注意: jq引擎需要能够找到并运行jq命令行程序。... 使用类似 XPath 的选择器
讲述了WebDriver-xpath和WebDriver-Css的学习摘要笔记,对于初学者还是很有用的,我也是转载的
24期爬虫-03-xpath数据解析-邓苏杭-歌曲排名.py
24期爬虫-03-xpath数据解析1-陈麟.py
JSONPath表达式 JSONPath表达式始终以与XPath表达式与XML文档结合使用的相同方式引用JSON结构。 由于JSON结构通常是匿名的,并且不一定具有根成员对象,因此JSONPath假定将抽象名称$分配给外部对象。 JSONPath表达式...
前端大厂最新面试题-xpath.docx
Python爬虫Chrome网页解析工具-XPath Helper插件
uiautomatorviewer 的增强版,能定位控件 xpath 路径,便于后续项目使用 用法: 将压缩包中的 jar 包替换掉原 uiautomatorviewer 的 jar 包,原 jar 包一般在 sdk\tools\lib 中,注意:jar 包名称需更改为原 jar 包...
Chrome插件-XPath Helper 完成Bing每日壁纸的小爬虫.zip。XPath是一个辅助我们写爬虫的小插件, 我们可以用XPath辅助我们完成一个Bing壁纸的小爬虫
js-xpath 使用Jison解析器/生成器JavaScript的XPath解析器/生成器。 演示版 有关解析xpath表达式的非常简单的用法,请参见文件。 用法 首先在文档中包含库以及xpath.js和models.js文件。 然后尝试以下操作以开始...
资源来自pypi官网,解压后可用。 资源全名:py_dom_xpath_six-0.2.4-py3-none-any.whl