Reactor

Structure Functions

Mappings: Functions and Expressions · Updated June 9, 2025

Element

Description

Returns the element at the supplied position in the list (1-based or starting from 1).

Syntax

ELEMENT(list, index)

ℹ️ This function is a complement of the Index Function.

Examples

  1. ELEMENT(["foo","bar","baz"],3) returns baz

Flatmap

Description

  1. Maps each value in the given list to a new list by application of a LAMBDA function to each value. Returns a combined list of all returned values. This function is the equivalent of running Flatten and Map together.
  2. Flatmap is a Lambda Helper function that can be used in conjunction with a Lambda function.

Syntax

FLATMAP(lambda, list)

Alternatively, the Lambda function could be written as an expression with the name as follows:

each

This is useful when calling all instances of a repeated attribute in source data. Typically, the each will be referenced in a Lambda Helper Function that supplies more information regarding the variable.

Examples

  1. FLATMAP([each, each + 1], [1, 2, 3]) returns [1, 2, 2, 3, 3, 4]

Flatten

Description

  1. Flattens all the values from one or more lists into a single list.

Syntax

FLATTEN(list, [list, ...])

Examples

  1. FLATTEN([[1,2],[2,4],[3,5]]) returns [1, 2, 2, 4, 3, 5]

Get

Description

  1. Retrieves the value of the field specified in a source object or array. The function returns NULL if the field is not found or the default if one is provided.
    • The field parameter must be wrapped in double quotes (")
    • source is a valid object name, representing the source object
    • The default parameter can be a quoted constant, another field, or a nested function.

Syntax

GET("field", object, default)

Examples

  1. GET("id",source,null) returns the value of the id field in the data source, or null if id is not present.

  2. GET("sku",source.line_items,null) returns the value of the sku field in the source data array line_items, or null if sku is not present.

    • :warning: This function will return an error if there is no line_items array in the source data
    • Null-handling for the line_items array can be incorporated using another GET function in the second position of the main GET function, with an empty object ({}) as the fallback value:
      • The additional GET function: GET("line_items",source,{})

      • The fully-nested GET function: GET("sku",GET("line_items",source,{}),null)

Index

Description

  1. Returns the position (1-based or starting from 1) within a list of a given value.

Syntax

INDEX(list, value)

ℹ️ This function is a complement of the Element function.

Examples

  1. INDEX(["foo","bar","baz"],"baz") returns 3

List

Description

  1. Creates a list with the elements specified.
  2. List is a Lambda Helper function that can be used in conjunction with a Lambda function. Additionally, List can be used to create name/value pairs, which are useful when mapping to properties labels in the Reactor Semantic models. 

Syntax

  1. To write a simple list function:
    LIST([elem, ...])
  2. To write a list of name/value pairs:
    LIST({"name":definition,"value":definition]}, [{"name":definition,"value":definition}, ...])
  3. name and value must be wrapped in double quotes (")
  4. The definition of a name must a string be wrapped in double quotes (")
  5. The definition of a value can be any combination of hard-coded values (wrapped in double quotes), functions, field references, metadata fields, or operators
  6. Multiple name-value pairs can be input, with pairs wrapped in squiggly brackets ({}) and commas separating the pairs

Examples

  1. LIST(1,2,3) returns [1,2,3]

  2. LIST({"name":"age","value":23}) returns [{'name': 'age', 'value': 23}]

  3. LIST({"name":"age","value":source.age}) returns a name/value pair with “age” as the name and the value of the source field age as the value

Map

Description

  1. Maps each value in the given list to a new value by application of a Lambda function to each value.
  2. Map is a Lambda Helper function that can be used in conjunction with a Lambda function.

Syntax

MAP(lambda, list)
  1. Alternatively, the Lambda function could be written as an expression with the name each as follows:
    each
  2. This is useful when calling all instances of a repeated attribute in source data. Typically, the each will be referenced in a Lambda Helper Function that supplies more information regarding the variable.
 

Examples

  1. MAP(each + 1, [1, 2, 3]) returns [2, 3, 4]

  2. For the following example, a source object (source) contains the following data:

    {"items":[
        { "sku":"123",
          "quantity":1,
          "price":29.99,
          "title":"watch"},
        {"sku":"456",
          "quantity":2,
          "price":4.99,
          "title":"strap"},
        {"sku":"789",
          "quantity":1,
          "price":2.99,
          "title":"cleaning cloth"}]}
MAP(each.quantity,GET("items",source,{})

returns

[1, 2, 1]