/ 工具
■/ 工具查找器
109 个工具
/ JSON Path 查找器
/ 所选工具
■JSON Path 查找器 - 免费 开发者 工具
使用 JSONPath 表达式从 JSON 中查找并提取值
■ 01
什么是 JSON Path?
JSON Path 是一种针对 JSON 的查询语言,类似于针对 XML 的 XPath。它让你可以使用路径表达式在 JSON 文档中导航并提取数据。该工具帮你测试和验证你的 JSON path 表达式。
■ 02
它是如何工作的?
路径语法 $ - 根元素 .property - 子属性 [0] - 数组索引 [*] - 所有元素 .. - 递归下降 [0:2] - 数组切片 [-1] - 最后一个元素 常见用例 从 API 响应中提取特定字段 查……询
■ 03
示例场景
涵盖简单属性访问、数组索引和通配符选择,让你可以快速比较常见的输入与输出。
/ 相关工具
/ 代码
■所选工具的源代码,显示在此处,右侧为实时运行版本。
/ 源代码
TypeScript
typescript
// Simple JSON Path implementation in TypeScript
// No external dependencies required
type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };
function extractJsonPath(obj: JsonValue, path: string): JsonValue[] {
const results: JsonValue[] = [];
// Remove leading $ if present
let normalizedPath = path.startsWith('$') ? path.slice(1) : path;