Complex functions

Complex functions let you read, validate, and update JSON data directly in a JSON string. Business processes often receive JSON from REST services, integrations, SmartObjects, controls, and workflow data fields. Instead of deserializing the JSON into a SmartObject, and again for every nested level, you can use a Complex function to get or set a value at a path.

Find the Complex functions in the Context Browser > Functions tab > Complex section and drag a function into any Type/Drop field. Then, in the Smartfield Composer, type or drag Functions, Fields, SmartObjects and Workflow related properties from the Context Browser to configure the function.

In SmartForms, find the same functions on the Add Expression page, in the Context Browser > Operators tab > Complex section. See Expressions.

You can use this, for example, when an approval workflow receives an order as JSON. The workflow uses Is Valid JSON to check the order, Path Exists to check whether customer.contact.email exists, and Get Value to read the email address. It then uses Set Value to update the order status, and Add Key Value to add audit details before it sends the updated JSON to another system.

Considerations

  • JSON property names and paths are case-sensitive.

  • Each function works on one JSON string and one path. To make more than one change, use the result of one function as the JSON string of the next.

  • Set Value, Add Key Value, and Remove Key read and rewrite the whole JSON, so indentation, spacing, and some number formats may change.

  • Set Value can't add a path that doesn't exist. Use Add Key Value instead.

  • Add Key Value replaces a property that already exists. It adds objects, but doesn't add arrays or array items.

  • Use Path Exists to distinguish between a property that doesn't exist and a property whose value is null.

  • Wildcards, recursive descent, filters, selecting more than one value, and negative array indexes aren't supported.

  • Is Valid JSON checks JSON syntax only. It isn't JSON Schema validation.

  • The whole JSON string is processed in memory, so the size of JSON you can use depends on the field it's stored in and on the server or browser resources.