Choice

Discover more about the Choice component and how to use it on the Digibee Integration Platform.

Choice allows flows to take different paths inside a pipeline. It's part of a components set that helps with the integrations organization.

Parameters

Take a look at the configuration options for the component. Parameters supported by Double Braces expressions are marked with (DB).

ParameterDescriptionDefault valueData type

Label

Defines the path name. It must be a unique name that can be repeated in the pipeline.

N/A

String

Type

Defines the structure of the different path your flow should take (When or Otherwise). Read the Type section to learn more.

When

String

Type Rule

Defines the language type (Simple or JSON Path), which will be used for the condition declaration (every time When gets chosen in the Type parameter). Read the Type Rule section to learn more.

JSON Path

String

Condition

Declares the condition used to define if the path must be executed. When the previously defined conditions generate conflict or cause an overlap, only one of them will be executed (every time When gets chosen in the Type parameter).

$

String

The configuration parameters will not be available if the component is not connected to other components in the pipeline. Once you connect it properly, just click at the connection point and then in the gear icon to access the parameters as shown in the image detail below:

Type

To work with this component, you must know two structure types of Choice. They're used to create the paths:

  • When: defines a condition that allows the flow to take a different path towards a specific execution line. You must declare at least one condition.

  • Otherwise: the structure is executed when none of the When conditions is attended. You must declare at least one condition.

Type Rule

JSON Path

Defines expressions that go through a JSON component to reach a subset. Whenever you use Choice, a match will be made for the path execution.

Imagine that, in the path that comes before Choice, your data flow has the following output:

{
    "city" : "New York"
}

The following condition declared as When validates the path your flow should take:

$.[?(@.city == 'New York')]

Know the other options for the JSON Path declaration:

JSON PathDescription

$

The object root or array.

.property

Selects a specific object in the related object.

['property']

Selects a specific property in the related object. Be sure to put only single quotes around the property name. Tip: consider this instruction if the property name has specific characters, such as spaces, or begins with a character other than A..Za..z_.

[n]

Selects the n-th element of an array. The indexes start with 0.

[index1,index2,…]

Selects array elements with specific indexes and returns a list.

..property

Recursive descent: searches for a specific property name recursively and returns an array with all the values with this property name. It always returns a list even if only 1 property is found.

*

Wildcard selects all the elements in an object or array, no matter that their names or indexes are. For example, address.* means all the properties of the address object and book[*] means all the items inside a book array.

[start:end] / [start:]

Selects elements of a start array and even, although not necessarily, an end array. If the end is omitted, select all the arrays until the end of the array. A list is returned.

[:n]

Selects the first n elements of the array. A list is returned.

[-n:]

Selects the last n elements of the array. A list is returned.

[?(expression)]

Filter expression. It selects all the elements in an object or array that match the specified filter. A list is returned.

[(expression)]

Script expressions can be used instead of explicit property names or indexes. For example, [(@.length-1)], that selects the last item of an array. Here, the length refers to the current array length more than a JSON file named "length".

@

Used for filter expressions to make reference to the current node that is being processed.

==

Equal to. 1 and '1' are considered the same result. String values must be attached in single quotes (and not in double quotes): [?(@.color=='red')].

!=

Different than. String values must be attached in single quotes.

>

Greater than.

>=

Greater than or equal to.

<

Less than.

<=

Less than or equal to.

=~

Compatible with a JavaScript RegEx. For example, [?(@.description =~ /cat.*/i)] matches items whose descriptions start with "cat" (case-insensitive).

!

Used to deny a filter. For example, [?(!@.isbn)] matches items that don't have the "isbn" property.

&&

Logical AND operator. Example: [?(@.category=='fiction' && @.price < 10)]

||

Logical OR operator. Example: [?(@.category=='fiction' || @.price < 10)]

Read this JSON Path article to learn more about the topic.

Simple

It's basically a small and simple language to evaluate expressions and predicates without demanding new dependences or JSON path knowledge.

Imagine that, in the path that comes before Choice, your data flow has the following output:

{
    "city" : "New York"
}

The condition declared as When validates the path your flow should take:

#{city} == 'New York'

Know the other options for the Simple declaration:

SimpleDescription

==

Equal to.

=~

Equal to, case-insensitive when comparing strings.

>

Greater than.

>=

Greater than or equal to.

<

Less than.

!=

Different.

!=~

Different than, case-insensitive when comparing strings.

regex

Validates if a string matches the specified RegEx. Example: #{city} regex 'New.*'

&&

Logical AND operator. Example: #{city} == 'New York' && #{state} == 'NY'

||

Logical OR operator. Example: #{city} == 'New York' || #{state} == 'CA'

Example:

Last updated