JMESPath

Last updated: 1 minute read.

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

Copy code
# Config fields, showing default values label: "" jmespath: query: "" # No default (required)

Note

For better performance and improved capabilities try out native Tyk Streams mapping with the mapping processor.

Fields

query

The JMESPath query to apply to messages.

Type: string

Examples

Mapping

When receiving JSON documents of the form:

Copy code
{ "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:

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

We can achieve this using the following config:

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