Create a JSON expression variable

Use a JSON expression variable to retrieve required data from the JSON string.

To retrieve data, give any JSON string and retrieve the JSON values as per Expression text(JSON path). For processing JSON, JSON path is required, similar to XPath for XML.

You can select a data object variable as your source JSON. You can also retrieve value of a specific field within a data object variable using expression text as your input and return data type as your output.

JSON path uses special notation to represent nodes and their connections to adjacent nodes in a JSON path. There are two styles of notation, namely dot ($.name) and bracket ($['name'] or [name]. The dollar sign ($) represents root member object.

  1. Open the process map in which to create the variable.
  2. On the process modeling bar, click Variables and click New.

    The New variable dialog box is displayed.

  3. Enter a unique Name for the variable.
    By default, the name of the variable becomes the ID of the variable; however, you can change the ID if needed.
  4. On the Type list, select JSON expression. (Default: String)
  5. Optional. To use the variable for process initialization, select Initialization.
  6. In the Expression text field, enter the JSON string, such as $, or $['person']['age'].
    At runtime, the data is retrieved as John or 25 respectively.
  7. To specify the source to use in the JSON variable, select a process or string variable in the Source JSON field.
    For example, use the following string variable: { "person" : { "name" : "John" , "age" : 25 , "city" : "New York" }, "company" : "kofax" }
    Note You can set the source variable of JSON expression as output to an activity. You cannot delete a source JSON variable if it is in use in JSON expression variable.
  8. On the Return data type list, select the return type of the JSON expression which can use any of the following formats: Bool (default), Byte, Currency, Date, Decimal, Double, Float, Long, Short, or String.
  9. Click OK.
  10. Click Save.