跳至主要内容

JSONPath 测试器

在线测试 JSONPath 表达式并实时查看结果:支持过滤器、通配符、递归下降和切片,显示匹配的值、路径和 JSON Pointer。

100% 客户端 · 没有数据离开您的浏览器
2 matches
Result
[
  "Sayings of the Century",
  "Moby Dick"
]

Syntax

$The root object
@The current item (inside filters)
.name or ['name']A child property
..Recursive descent: search all levels
*Every child (wildcard)
[n]Array index; negative counts from the end
[a,b]Several indexes or names
[start:end:step]Array slice
[?(expr)]Filter: ==, ===, !=, <, <=, >, >=, &&, ||, !
^Parent of the match (jsonpath-plus)
~Property names instead of values (jsonpath-plus)

Filters run in a sandboxed interpreter (jsonpath-plus “safe” mode): comparisons, &&, || and property access work; arbitrary JavaScript never runs.

关于此工具

编写 JSONPath 表达式,匹配结果会随输入实时更新。结果可显示为值、规范化路径或 JSON Pointer。测试器支持完整语法:点号和方括号表示法、通配符、递归下降(..)、数组切片和负索引、联合,以及包含比较运算、&& 和 || 的过滤表达式,还可以用 $ 引用根文档。14 个可点击的示例和一张语法表可帮助您快速上手,示例使用经典的 bookstore 示例数据。过滤器在沙箱解释器中运行,因此表达式中的 JavaScript 绝不会被执行,您的 JSON 也始终保留在浏览器中。

如何测试 JSONPath 表达式

在您的 JSON 上试用 JSONPath 查询。

  1. 1

    粘贴 JSON

    粘贴一个 JSON 文档,或使用 bookstore 示例数据。

  2. 2

    编写表达式

    输入 JSONPath,例如 $..book[?(@.price < 10)].title,或点击一个示例。

  3. 3

    查看匹配结果

    查看匹配的值,或切换为路径或 JSON Pointer 并复制。