JSONPath 解析工具
JSON 路径解析工具,支持 JSON 编辑、格式校验和 JSONPath 查询
JSON 输入
["Nigel Rees","Evelyn Waugh","Herman Melville","J. R. R. Tolkien"]
JSONPath 常用语法
| 符号 | 描述 | 示例 | 结果 | 操作 |
|---|---|---|---|---|
| $ | 根对象 | $ | 整个JSON对象 [
{
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
... | |
| . | 子节点 | $.store.book | book数组 [
[
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn ... | |
| .. | 递归查找 | $..author | 所有author字段 [ "Nigel Rees", "Evelyn Waugh", "Herman Melville", "J. R. R. Tolkien" ] | |
| * | 通配符 | $.store.book[*].author | 所有书的作者 [ "Nigel Rees", "Evelyn Waugh", "Herman Melville", "J. R. R. Tolkien" ] | |
| [] | 数组索引 | $.store.book[0] | 第一本书 [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
}
] | |
| [-1] | 最后一个元素 | $.store.book[-1] | 最后一本书 [] | |
| [n:m] | 数组切片 | $.store.book[0:2] | 前两本书 [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "... | |
| [?()] | 过滤表达式 | $.store.book[?(@.price<10)] | 价格小于10的书 [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Herman Melville",
"title"... |
工具说明
JSONPath 适合从复杂 JSON 结构中快速定位字段、提取数组内容和做接口联调排查。这个工具支持在线输入 JSON、编写表达式并即时查看结果。
你可以直接使用页面内置示例,也可以把接口返回值粘贴进来,结合常用语法表快速验证表达式写法。
常见问题
Q: 为什么表达式没有结果?
A: 通常是路径写错、字段名不匹配,或者当前 JSON 结构与预期不一致。
Q: 适合什么场景?
A: 接口联调、日志排查、Mock 数据验证、复杂 JSON 提取和自动化测试场景都很适合。