CloudFlow's Flow Definition Language (FDL) provides built-in functions for data processing within workflow definitions. Use these functions to manipulate strings, arrays, maps, and JSON data without writing external function code.
To use a built-in function in an input or output constructor, append .$ to the constructor key. This tells CloudFlow to evaluate the value as an expression. Without the .$ suffix, the value is treated as a plain string. A maximum of 10 nested function calls are supported per expression.
Example: Using a built-in function in an FDL constructor
{
"inputMappings": {
"greeting.$": "format('Hello, {}', $input.username)"
}
}In this example, greeting.$ tells CloudFlow that the value is an expression containing the format function, not a literal string.
Function reference
The following tables list all built-in functions, grouped by category.
Common operations
| Function | Purpose |
|---|---|
format | Format a string using {} placeholders |
length | Get the length of a string, array, or map |
regexMatchString | Match a string against a regular expression |
split | Split a string by a delimiter |
Array operations
| Function | Purpose |
|---|---|
arrayContains | Check whether an array contains a specific element |
arrayUnique | Remove duplicate elements from an array |
toArray | Convert a variable number of arguments into an array |
Map operations
| Function | Purpose |
|---|---|
mapKeys | Extract all keys from a JSON object or map as an array |
mapValues | Extract all values from a JSON object or map as an array |
mapValuesPartition | Extract values from a map and split them into sub-arrays by step size |
Data encoding and decoding
| Function | Purpose |
|---|---|
toBase64 | Encode a string to Base64 |
fromBase64 | Decode a Base64-encoded string |
Hash calculation and UUID generation
| Function | Purpose |
|---|---|
hash | Generate a hash value using a specified algorithm |
uuid | Generate a universally unique identifier (UUID) |
JSON data operations
| Function | Purpose |
|---|---|
jsonToString | Convert a JSON object or map to a JSON string |
stringToJson | Parse a JSON string into a JSON object or map |
jsonMerge | Merge two JSON objects or maps into one |
Common operations
format
Formats a string by replacing {} placeholders with the provided arguments, in order.
Syntax
format(template, arg1, arg2, ...)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| template | string | Yes | A template string containing {} placeholders |
| arg1, arg2, ... | any | Yes | Values to substitute into the placeholders, in order |
Return type: string
Examples
format("hello {}", "world")
// Returns: "hello world"FDL usage:
{
"message.$": "format('Task {} completed at {}', $input.taskName, $input.timestamp)"
}length
Returns the length of a string, array, or map.
For a string, returns the number of characters.
For an array, returns the number of elements.
For a map, returns the number of key-value pairs.
Syntax
length(value)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | string, []any, or map[string]any | Yes | The string, array, or map to measure |
Return type: int
Examples
length([1, 2, 3])
// Returns: 3
length({"name": "Tom", "age": 10})
// Returns: 2
length("name")
// Returns: 4FDL usage:
{
"itemCount.$": "length($input.orderItems)"
}regexMatchString
Tests whether a string matches a regular expression pattern. Returns true if the pattern matches, false otherwise.
Syntax
regexMatchString(pattern, value)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| pattern | string | Yes | The regular expression pattern |
| value | string | Yes | The string to test against the pattern |
Return type: bool
Examples
regexMatchString("p([a-z]+)ch", "peach")
// Returns: true
regexMatchString("p([a-z]+)ch", "p123ch")
// Returns: falseFDL usage:
{
"isValid.$": "regexMatchString('^[a-zA-Z0-9]+$', $input.userId)"
}split
Splits a string into an array of substrings based on a delimiter.
Syntax
split(value, delimiter)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | string | Yes | The string to split |
| delimiter | string | Yes | The delimiter to split on |
Return type: []string
Examples
split("item1,item2,item3", ",")
// Returns: ["item1", "item2", "item3"]FDL usage:
{
"tags.$": "split($input.tagString, ',')"
}Array operations
arrayContains
Checks whether an array contains a specific element. Returns true if the element is found, false otherwise.
Syntax
arrayContains(array, element)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| array | []any | Yes | The array to search |
| element | any | Yes | The element to search for |
Return type: bool
Examples
arrayContains(["Tom", 10], 10)
// Returns: true
arrayContains(["Tom", 10], "Jack")
// Returns: falseFDL usage:
{
"isAllowed.$": "arrayContains($input.allowedRegions, $input.targetRegion)"
}arrayUnique
Removes duplicate elements from an array and returns the deduplicated result.
Syntax
arrayUnique(array)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| array | []any | Yes | The array to deduplicate |
Return type: []any
Examples
arrayUnique([1, 2, 3, 1])
// Returns: [1, 2, 3]toArray
Converts a variable number of arguments into a single array.
Syntax
toArray(arg1, arg2, ...)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| arg1, arg2, ... | any | Yes | One or more values to combine into an array |
Return type: []any
Examples
toArray(1,'strig',$Input.var)
// Returns: []any{1, 'string', $valueOfVar}Map operations
mapKeys
Extracts all keys from a JSON object or map and returns them as a string array.
Syntax
mapKeys(map)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| map | map[string]any | Yes | The JSON object or map to extract keys from |
Return type: []string
Examples
mapKeys({"name": "Tom", "age": 10})
// Returns: ["name", "age"]mapValues
Extracts all values from a JSON object or map and returns them as an array.
Syntax
mapValues(map)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| map | map[string]any | Yes | The JSON object or map to extract values from |
Return type: []any
Examples
mapValues({"name": "Tom", "age": 10})
// Returns: ["Tom", 10]mapValuesPartition
Extracts all values from a JSON object or map and partitions them into sub-arrays of a specified size.
Syntax
mapValuesPartition(map, stepSize)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| map | map[string]any | Yes | The JSON object or map to extract values from |
| stepSize | int | Yes | The number of elements per sub-array |
Return type: [][]any
Examples
mapValuesPartition({"name": "Tom", "age": 10}, 1)
// Returns: ["Tom"],[10]Data encoding and decoding
toBase64
Encodes a string to Base64.
Syntax
toBase64(value)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | string | Yes | The string to encode |
Return type: string
Examples
toBase64("FnF")
// Returns: "Rm5G"fromBase64
Decodes a Base64-encoded string back to its original value.
Syntax
fromBase64(value)
ParametersParameterTypeRequiredDescriptionvaluestringYesThe Base64-encoded string to decode
Return type: string
ExamplesfromBase64("Rm5G")
// Returns: "FnF"Hash calculation and UUID generation
hash
Generates a hash value for the given input using a specified algorithm.
Syntax
id="dfc2079465bd1_19"Code" data-tag="codeblock" id="dfc2079465bd1" outputclass="language-bash">hash(input, algorithm)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | string | Yes | The string to hash |
| algorithm | string | Yes | The hash algorithm. Supported values: MD5, SHA-1, SHA-256, SHA-512 |
Return type: string
Examples
hash("abc", "MD5")
// Returns: "900150983cd24fb0d6963f7d28e17f72"FDL usage:
{
"checksum.$": "hash($input.payload, 'SHA-256')"
}uuid
Generates a universally unique identifier (UUID).
Syntaxuuid()
Parameters
None.
Return type: string
Examples
uuid()
// Returns: "159fd8c1-2ec3-4d7b-b9fd-60b9d8841000"FDL uid="dfc2079465bd1_22"e-type="xCode" data-tag="codeblock" id="dfc2079465bd1" outputclass="language-json">{ "requestId.$": "uuid()" }
JSON data operations
jsonToString
Converts a JSON object or map to its string representation.
Syid="dfc2079465bd1_23"code-type="xCode" data-tag="codeblock" id="dfc2079465bd1" outputclass="language-bash">jsonToString(value)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | map[string]any | Yes | The JSON object or map to serialize |
Return type: string
Examples
toJSON({"name": "Tom", "age": 10})
// Returns: '{"name": "Tom", "age": 10}'stringToJson
Parses a JSON string into a JSON object or map.
Syntax
stringToJson(value)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | string | Yes | A valid JSON string |
Return type: map[string]any
Examples
stringToJson('{"name": "Tom", "age": 10}')
// Returns: {"name": "Tom", "age": 10}FDL usage:
{
"parsedBody.$": "stringToJson($input.responseBody)"
}jsonMerge
Merges two JSON objects or maps into one.
jsonMerge(object1, object2)
ParametersParameterTypeRequiredDescriptionobject1map[string]anyYesThe first JSON object or mapobject2map[string]anyYesThe second JSON object or map
Return type: map[string]any
ExamplesjsonMerge({"name": "Tom", "age": 10}, {"name": "Tom", "address": "beijing"})
// Returns: {"name": "Tom", "age": 10, "address": "beijing"}
{
"mergedConfig.$": "jsonMerge($input.defaultConfig, $input.userOverrides)"
}