Table of Contents

JSONValue

The %JSONValue%jsonpath% token returns the JSON value from the specified JSON path).

The token has Pretty and Compact variants (by appending either to the token name), as well as a Strict variant (appending Strict) (for example %JSONValueStrictCompact%jsonpath%). The order of the variants does not matter, but you cannot have both Compact and Pretty (See the JSON user manual section).

Strict mode affects how the result will be returned. In Strict mode, the result will be a strict JSON objects - strings will be double quoted and appropriately escaped. In Non-Strict mode, string results will be returned as the decoded and de-quoted string. Other types of results will be the same regardless of the Strict mode (containers are always be strictly JSON objects) (See the JSON user manual section).

Examples

If a Keyboard Maestro variable J contains the JSON object:

{"a":9, "b":"bravo", "c":null, "d":[11,"two",33]}

Then these would be the results:

Token Result Comment
%JSONValue%J.a% 9 (Variants have no affect)
%JSONValue%J.b% bravo (Compact/Pretty variant has no affect)
%JSONValueStrict%J.b% "bravo" (Compact/Pretty variant has no affect)
%JSONValue%J.c% null (Variants have no affect)
%JSONValue%J.d% [11,"two",33] (Same as JSONValueCompact, Strict variant has no affect)
%JSONValuePretty%J.d% [\n\t11,\n\t"two",\n\t33\n] (\t is some form of indenting)
%JSONValue%J.d[2]% two (Compact/Pretty variant has no affect)
%JSONValueStrict%J.d[2]% "two" (Compact/Pretty variant has no affect)
%JSONValue%J.d[0]% 3 (Variants have no affect)
%JSONValue%J.d[-2]% two (the second last entry)
%JSONValue%J.d[COUNT()]% 3 (the last entry)

The exact format of the white space in the Pretty format should not be assumed, it might be any number of spaces or tabs.

See Also

See the JSON user manual section for more details on JSON.

Actions

Functions

Tokens

Collections