JSON Path

Read with AI
All docs in one file (llms-full.txt)
JsonPath #Operation #Node
JSON Path

It pulls the one value specified by a path out of the JSON string arriving at JSON and outputs it. Use it as the partner that receives HTTP Request’s Body directly.

The path format

You dig into object keys with . and into arrays with [n].

  • syncedLyrics — a top-level key
  • [0].syncedLyrics — a key on the first element of an array
  • data.items[2].name — nested

Whitespace around the path is stripped before it is used. If you leave the path empty, the whole JSON comes out of Out as it is.

You can give the path either by writing it in the field on the node body or by feeding it into the Path port.

The three outputs

  • Out — if the value pulled out is a string, its contents. If it is an object or an array, it comes out as JSON text, so you can dig further with another JSON Path downstream. Numbers and booleans come out in their text notation
  • Number — the value itself for a number, 1 for true and 0 for false for a boolean, and a string that can be read as a number also becomes a number. Anything else is 0
  • Found — whether a value could be pulled out

All three are output only when the value differs from last time.

When nothing could be pulled out

In any of the following, Out becomes an empty string, Number becomes 0 and Found becomes false. You can check what happened in the small text on the node.

  • JSON is empty, or nothing but whitespace
  • A string arrived that cannot be read as JSON (the API returned an HTML error page, for example)
  • The path format is invalid
  • What the path points at does not exist, or the value is null

When a value could be pulled out, the display on the node changes to match the kind of that value.

Input ports

Port IDType
JSONstring
Pathstring

Output ports

Port IDType
Outstring
Numberfloat
Foundbool

Scriptable members

PathType
jsonInputstring
pathInputstring
currentPathstring

Synapse Apps (scripting)

await synapse.modules.create({ type: "JsonPath" })

Pages linking here

Also referenced from