Skip to main content

jmespath

Executes a JMESPath query on JSON documents and replaces the message with the resulting document.

# Common config fields, showing default values
label: ""
jmespath:
query: ""
Try out Bloblang

For better performance and improved capabilities try out native Benthos mapping with the bloblang processor.

Fields​

query​

The JMESPath query to apply to messages.

Type: string
Default: ""

parts​

An optional array of message indexes of a batch that the processor should apply to. If left empty all messages are processed. This field is only applicable when batching messages at the input level.

Indexes can be negative, and if so the part will be selected from the end counting backwards starting from -1.

Type: array
Default: []

Examples​

When receiving JSON documents of the form:

{
"locations": [
{"name": "Seattle", "state": "WA"},
{"name": "New York", "state": "NY"},
{"name": "Bellevue", "state": "WA"},
{"name": "Olympia", "state": "WA"}
]
}

We could collapse the location names from the state of Washington into a field Cities:

{"Cities": "Bellevue, Olympia, Seattle"}

With the following config:

pipeline:
processors:
- jmespath:
query: "locations[?state == 'WA'].name | sort(@) | {Cities: join(', ', @)}"