queryJson
@forge/monorepo / backend/src / queryJson
Function: queryJson()
queryJson(
document,path):JsonQueryResult
Defined in: backend/src/toolkit/data.ts:135
Read a value out of a JSON document by path.
A deliberately small path language -- a.b, a.0.b, a[0].b, and * for "every element or value here" --
because the alternatives are a JSONPath dependency or eval, and one of those is a remote code execution in a
tool whose argument comes from a model.
The point of the tool is that a model can pull one field out of a 200KB payload without the payload passing through its context. A tool that returns the whole document on a bad path defeats that, so a path matching nothing returns no matches and says so.
Parameters
document
unknown
path
string