JSON Path 查询工具
免费在线 JSONPath / JMESPath 查询工具,支持路径高亮与常用查询示例
JSON 编辑器|
36 行748 字符✓ JSON 有效
支持 $..author, $.store.book[?(@.price<10)]
$
快捷示例:
查询结果
执行查询后结果将在此显示
选择模式,输入查询表达式,按 执行 或 Enter
生成代码
// npm install jsonpath-plus const { JSONPath } = require('jsonpath-plus'); const data = { "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 } } }; const raw = JSONPath({ path: "$..author", json: data }); const result = raw; // result 类型: any[][]
JSONPath 语法参考点击展开/折叠
| 语法 | 说明 | 示例 |
|---|---|---|
$ | 根节点 | $ |
.property | 子节点访问 | $.store.book |
[n] | 数组索引访问 | $.store.book[0] |
[*] | 所有数组元素 | $.store.book[*] |
.. | 递归下降 | $..author |
[start:end] | 数组切片 | $.store.book[0:2] |
[?(expr)] | 过滤表达式 | $.store.book[?(@.price < 10)] |
== != < > <= >= | 过滤比较运算符 | $.store.book[?(@.category == "fiction")] |