Browse the docs

json

Parses JSON text into a list, record, number, text or true/false.

Details #

json(text) takes exactly one argument and returns whatever the JSON describes. Use it on the output of a shell command, a web request or a file, then read fields with .name and [index].

Parameters #

Takes 1 argument. {{ json(text) }}

Examples #

json(raw).name
→ Ada
Sample variableValue
raw{"name": "Ada", "tags": ["x", "y"]}
json(raw).tags[1]
→ y
Sample variableValue
raw{"name": "Ada", "tags": ["x", "y"]}
length(json("[1,2,3]"))
→ 3

Gotchas #

  • Text that isn't valid JSON is an error: json() got text that isn't valid JSON.

  • A missing field reads as nothing (null), not an error.