User Tools

Site Tools


action:Set_JSON_Value

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

Set JSON Value

The Set JSON Value (v9.0+) action lets you update a Keyboard Maestro variable containing a JSON container with a new value.

 Set JSON Value

The action will take a specified JSON path, referencing a location within a variable which contains a JSON object, and set the value.

For example, with variable “J” containing { "first" : "John", "last" : "Smith" }, the action can set the fist name field J.first (or J{first}) to a new name.

The value will be considered a JSON object if it starts with a [ or { and ends with the matching closing bracket and optional white space. Otherwise, the value will be considered a string (Non-Strict mode), or must be a valid JSON value (Strict Mode).

Action Options (Gear ⚙ Menu)

You can control what text processing happens in the JSON field by selecting one of these options from the Gear Menu:

  • Process Text Normally (process text tokens and backslash characters)
  • Process Text Tokens Only (process text tokens but not backslash characters)
  • Process Nothing (process neither text tokens nor backslash characters)

You can select Pretty JSON result mode, which affects the format of the entire resulting variable value (See JSON).

You can select Strict JSON result mode, which affects how the value field is interpreted - in Strict mode, strings will need to be quoted with double quotes and appropriately escaped, but you can also then set numeric values and tru/false/null values. In Non-Strict mode, the value is treated as a string and quoted and escaped as necessary (See JSON).

See Also

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

Actions

Tokens

action/Set_JSON_Value.1561356404.txt.gz · Last modified: 2019/06/24 02:06 by peternlewis