User Tools

Site Tools


token:JSONValue

Table of Contents

**This is an old revision of the document!**

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).

  • JSONValue (equivalent to JSONValueCompact)
  • JSONValueCompact
  • JSONValuePretty
  • JSONValueStrictCompact
  • JSONValueStrictPretty

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).

Example

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)
%JSONValueStrict%J.d[0]% 3 (Variants have no affect)

See Also

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

Actions

Functions

Tokens

token/JSONValue.1561366818.txt.gz · Last modified: 2019/06/24 05:00 by peternlewis