The functions were created to:

  • speed up the creation of your integrations even more

  • decrease the complexity of your pipelines

  • simplify data conversions and transformations during the flow of your pipelines

The utilities functions make diverse operations, which don't fit any of the other categories and are available for components that support Double Braces expressions. To know how to provide information to the components using this resource, click here.

BASEDECODE

This function in Double Braces decodes a string in a base64 format.

Syntax

BASEDECODE(value:string, [charset:string - optional])

  • value: string to be decoded

  • charset: charset for the decodification (standard = UTF-8) (optional)

Let's say you need to decode a string. You can do the following:

{
"test": {{ BASEDECODE("eHB0bw==", "UTF-8") }}
}

The expected result will be:

{
"test": "xpto"
}

BASEENCODE

This function in Double Braces codes a string in a base64 format.

Syntax

BASEENCODE(value:string, [charset:string - optional])

  • value: string to be coded

  • charset: charset for the codification (standard = UTF-8) (optional)

Let's say you need to code a string. You can do the following:

{
"test": {{ BASEENCODE("xpto", "UTF-8") }}
}

The expected result will be:

{
"test": "eHB0bw=="
}

UUID

This function in Double Braces generates an unique universal identificator - the number of 128 bits is used to identify information in systems.

Syntax

UUID()

Let's say you need to generate an unique identificator. You can do the following:

{
"test": {{ UUID() }}
}

The expected result will be:

{
"test": "4caad555-09b5-479c-98b4-ac72ffbb486c"
}

TOBOOLEAN

By using Double Braces, you can combine the function with the access to the input JSON element of a component.

The function allows you to convert a string value to boolean.

Syntax

TOBOOLEAN(value)

Let's say you need to convert the values below to boolean:

{
"string": "false",
"stringUpperCase": "TRUE",
"boolean": true,
"integer": 1,
"nullValue": null,
"object": {
"string": "abc"
}
}

Converting the values:

{
"string": {{ TOBOOLEAN(message.string) }},
"stringUpperCase": {{ TOBOOLEAN(message.stringUpperCase) }},
"boolean": {{ TOBOOLEAN(message.boolean) }},
"integer": {{ TOBOOLEAN(message.integer) }},
"nullValue": {{ TOBOOLEAN(message.nullValue) }},
"object": {{ TOBOOLEAN(message.object) }}
}

The result will be:

{
"string": false,
"stringUpperCase": true,
"boolean": true,
"integer": false,
"nullValue": false,
"object": false
}

If the function is applied in strings with different values of "true", "false", "TRUE" and "FALSE", numerical fields, null fields, objects and arrays, the function will always return the result false.

SIZE

This function in Double Braces allows the size of strings, arrays and objects to be obtained.

Syntax

SIZE(value, [throwErrorOnUnexpectedType:boolean - optional])

  • value: value to be checked the size

  • throwErrorOnUnexpectedType: indicates whether an exception will be returned when the value parameter isn’t expected by the function. If not informed, a true value will be assumed and, when a false value is informed, the function's return will be null.

Let's say you need to get the size of a text from a comments property contained in your payload. You can use the following snippet in the JSON Generator component:

{
"commentsSize": {{ SIZE(message.comments) }}
}

The result will be a numeric value corresponding to the number of characters contained in the text:

{
"commentsSize": 1000
}

Now imagine there’s a JSON object in the following structure:

{
"body":{
"field1": "test",
"field2": {
"field2.1": "testing"
}
}
}

The size of this object must be checked. If using JSON Generator again, the following snippet must be configured:

{
"bodySize": {{ SIZE(message.body) }}
}

The result will be the amount of properties contained in the body object:

{
"bodySize": 2
}

In this case, the function only considers properties that directly belong to the body object and doesn’t consider nested properties.

You can also check the size of an array:

{
"array": [
10,20,30
]
}

Considering the array above, use JSON Generator one more time to configure the following snippet:

{
"arraySize": {{ SIZE(message.array) }}
}

When executing the function, the result will represent the number of elements contained in the array:

{
"arraySize": 3
}

The SIZE function expects string, array and object value types. When the value doesn’t match this requirement, an exception will be thrown. However, it’s also possible to configure the function not to throw an exception and simply return null. If that’s the case, just configure the second parameter of the function with the value false.

Consider the following payload:

{
"elements": 13
}

And the following JSON Generator configuration:

{
"elementsSize": {{ SIZE(message.elements, false) }}
}

The result of the function execution will be:

{
"elementsSize": null
}

That way, no exception will be thrown and some verification logic can be adopted in your integration flow.

You can also read about these functions:

Did this answer your question?