JSON and Step Actions

A number of step actions work only on JSON; the data presented in the current window must be JSON (and not JSON in the legacy format where JSON has been translated into XML). These step actions are found in the step action category called JSON in the Step Action Selector on the Action tab of the Step View. But the easiest way to select them is to use the context menu (right-click menu) in the Applications View when the current window contains JSON. See the following sample image.


JSON step action example

Two step actions can extract from a JSON value:

  • Extract JSON. This step action always extracts a JSON value. For exampl, if the selection in the view is a property, it is the value of the property that is extracted. It is in many ways similar to the Extract step that extracts from HTML and XML, except that it is simpler because of the simpler data format; no distinction exists between markup and text.
  • Extract Property Name. This step action extracts the name of a property.

Two step actions can loop over a JSON text:

  • For Each Property. This step action loops over each property of a JSON object
  • For Each Item. This step action loops over each JSON value of a JSON array.

Both of step actions will for each iteration set a part of the JSON value in question as named JSON (similar to a named tag). This cannot be global when iterating over a variable, since changing the value of a variable during the iteration may change the value in such a way that iteration may fail, such as if an item is removed from the list iterated over.

Four step actions can modify JSON (only if the JSON is in a variable):

  • Set JSON. Replaces the selected part of a JSON value with a new JSON value.
  • Set Property Name. Sets the property name to a new name on a selected property.
  • Insert JSON. Inserts a new property in a JSON object or a new item (JSON value) in a JSON array. There are several options on where to insert the new property or item, such as first or last. Consult the reference documentation for the step action for a full list.
  • Remove JSON. Removes the selected part of a JSON value, such as a property from a JSON object or an item from a JSON array.

Finally, two more step actions work on JSON:

  • Test JSON. This step action tests the "type" of a JSON value to determine whether it is an object, array, string, etc.
  • Set Named JSON. This step action is similar to its corresponding step action for other types of data, such as Set Named Tag and Set Named Range. It defines a named reference to a part of a JSON value so that it can be used as a reference when finding other parts of a JSON value in subsequent steps. Shown as blue boxes in the view.