Skip to main content
Version: 1.2.0
Text Processing String Manipulation Data Cleaning

Join KV

Synopsis

Converts a map of key-value pairs to a formatted string.

Schema

- join_kv:
field: <ident>
target_field: <ident>
separator: <string>
kv_separator: <string>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>

Configuration

The following fields are used to define the processor:

FieldRequiredDefaultDescription
fieldY-Source field containing the map of key-value pairs
target_fieldY-Destination field to store the resulting string
separatorN;Character(s) used to separate key-value pairs
kv_separatorN=Character(s) used to separate keys from values
descriptionN-Explanatory note
ifN-Condition to run
ignore_failureNfalseContinue processing if conversion fails
ignore_missingNfalseSkip if source field doesn't exist
on_failureN-Error handling processors
on_successN-Success handling processors
tagN-Identifier

Details

Converts a map (object) of key-value pairs into a single formatted string. The processor joins all key-value pairs from the source map using specified separators, creating a consistent string representation of the structured data.

note

Keys in the resulting string are always sorted alphabetically to ensure consistent output regardless of the original map order. This makes the output deterministic, which is important for scenarios like generating hash values or signatures from the string.

The processor sorts keys alphabetically to ensure consistent output ordering, which is useful for creating deterministic string representations of maps for logging, display, or further processing.

warning

When converting complex nested objects, only the string representation of the value is included. Nested objects will be formatted using their default string representation, which may not be ideal in all cases. For complex nested structures, consider flattening the data first.

Examples

Basic

Converting map to string using default separators...

{
"user": {
"attributes": {
"name": "John",
"role": "admin",
"active": true
}
}
}
- join_kv:
field: user.attributes
target_field: user.attributes_string

creates a string with default separators:

{
"user": {
"attributes": {
"name": "John",
"role": "admin",
"active": true
},
"attributes_string": "active=true;name=John;role=admin"
}
}

Custom

Using custom field and pair separators...

{
"request": {
"headers": {
"content-type": "application/json",
"user-agent": "Mozilla/5.0",
"accept": "text/html"
}
}
}
- join_kv:
field: request.headers
target_field: request.header_string
separator: ", "
kv_separator: ": "

formats headers in HTTP style:

{
"request": {
"headers": {
"content-type": "application/json",
"user-agent": "Mozilla/5.0",
"accept": "text/html"
},
"header_string": "accept: text/html, content-type: application/json, user-agent: Mozilla/5.0"
}
}

URL Queries

Creating a URL query string format...

{
"query": {
"params": {
"q": "search term",
"page": 1,
"limit": 25
}
}
}
- join_kv:
field: query.params
target_field: query.string
separator: "&"
kv_separator: "="

builds a properly formatted query string:

{
"query": {
"params": {
"q": "search term",
"page": 1,
"limit": 25
},
"string": "limit=25&page=1&q=search term"
}
}

Field Tags

Formatting a map with XML-style tags...

{
"metrics": {
"cpu": 75.2,
"memory": 85.6,
"disk": 45.3
}
}
- join_kv:
field: metrics
target_field: metrics_string
separator: " "
kv_separator: "=\""
on_success:
- set:
field: metrics_string
value: "{{metrics_string}}\""

with additional processing:

{
"metrics": {
"cpu": 75.2,
"memory": 85.6,
"disk": 45.3
},
"metrics_string": "cpu=\"75.2\" disk=\"45.3\" memory=\"85.6\""
}