Browse the docs

jsonValue

Returns the value at a JSON path, from the given JSON or from the variable `json`.

Keyboard Maestro: JSONVALUE

Details #

jsonValue(path) or jsonValue(json, path) takes one or two arguments.

With two, it reads path in json (a record, list or JSON text), exactly as jsonPath does. With one, the argument is the path and the JSON comes from the variable json, or failing that kmJSON.

A path that leads nowhere gives empty text.

Parameters #

Takes 1 to 2 arguments. {{ jsonValue(text, b?) }}

Examples #

jsonValue(data, "a.b[0]")
→ 10
Sample variableValue
data{"a": {"b": [10, 20]}}
jsonValue("a.b[1]")
→ 20
Sample variableValue
json{"a": {"b": [10, 20]}}

Gotchas #

  • With no JSON to read it stops: jsonValue() has no JSON to read: give it the JSON as the first argument, or set a variable named json.

  • Text that isn't valid JSON counts as no JSON, so it stops with the same message (unlike jsonPath, which names the bad text).