> For the complete documentation index, see [llms.txt](https://doc.duaer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.duaer.com/zh/code/cookbook/jmespath.md).

# 在 Duaer 里用 JMESPath 查询 JSON

在 Duaer 里用 $jmespath(对象, "查询") 查询 JSON。表达式和 JavaScript Code 节点可用；Python Code 节点没有。
## $jmespath 读哪一份数据

第一个参数是要查的对象，通常是 $json 或前面某个节点的一项。第二个参数是 JMESPath 字符串。查询在这一次执行的数据上计算，不会改原来的项。

点号路径够用时，直接写 $json.body.city。要过滤数组、投影字段时再用 JMESPath。

```
{{ $jmespath($json, "body.city") }}
```

## 哪里能调用

- 表达式里可以调用 $jmespath()。
- JavaScript Code 节点里也可以调用。
- Python Code 节点没有 $jmespath。用 Python 自己的字典和列表来取字段。
## Questions

### 在 Duaer 里 $jmespath 有几个参数？

在 Duaer 里两个：第一个是要查的 JSON（通常是 $json），第二个是 JMESPath 字符串。查询不改原来的项。

### Duaer 的 Python Code 节点能调用 $jmespath 吗？

不能。Duaer 表达式和 JavaScript Code 节点可以用。Python Code 节点用字典和列表读字段。

