github.com/Jeffail/benthos/v3@v3.65.0/website/docs/components/processors/jmespath.md (about) 1 --- 2 title: jmespath 3 type: processor 4 status: stable 5 categories: ["Mapping"] 6 --- 7 8 <!-- 9 THIS FILE IS AUTOGENERATED! 10 11 To make changes please edit the contents of: 12 lib/processor/jmespath.go 13 --> 14 15 import Tabs from '@theme/Tabs'; 16 import TabItem from '@theme/TabItem'; 17 18 19 Executes a [JMESPath query](http://jmespath.org/) on JSON documents and replaces 20 the message with the resulting document. 21 22 23 <Tabs defaultValue="common" values={[ 24 { label: 'Common', value: 'common', }, 25 { label: 'Advanced', value: 'advanced', }, 26 ]}> 27 28 <TabItem value="common"> 29 30 ```yaml 31 # Common config fields, showing default values 32 label: "" 33 jmespath: 34 query: "" 35 ``` 36 37 </TabItem> 38 <TabItem value="advanced"> 39 40 ```yaml 41 # All config fields, showing default values 42 label: "" 43 jmespath: 44 query: "" 45 parts: [] 46 ``` 47 48 </TabItem> 49 </Tabs> 50 51 :::note Try out Bloblang 52 For better performance and improved capabilities try out native Benthos mapping with the [bloblang processor](/docs/components/processors/bloblang). 53 ::: 54 55 56 ## Fields 57 58 ### `query` 59 60 The JMESPath query to apply to messages. 61 62 63 Type: `string` 64 Default: `""` 65 66 ### `parts` 67 68 An optional array of message indexes of a batch that the processor should apply to. 69 If left empty all messages are processed. This field is only applicable when 70 batching messages [at the input level](/docs/configuration/batching). 71 72 Indexes can be negative, and if so the part will be selected from the end 73 counting backwards starting from -1. 74 75 76 Type: `array` 77 Default: `[]` 78 79 ## Examples 80 81 <Tabs defaultValue="Mapping" values={[ 82 { label: 'Mapping', value: 'Mapping', }, 83 ]}> 84 85 <TabItem value="Mapping"> 86 87 88 When receiving JSON documents of the form: 89 90 ```json 91 { 92 "locations": [ 93 {"name": "Seattle", "state": "WA"}, 94 {"name": "New York", "state": "NY"}, 95 {"name": "Bellevue", "state": "WA"}, 96 {"name": "Olympia", "state": "WA"} 97 ] 98 } 99 ``` 100 101 We could collapse the location names from the state of Washington into a field `Cities`: 102 103 ```json 104 {"Cities": "Bellevue, Olympia, Seattle"} 105 ``` 106 107 With the following config: 108 109 ```yaml 110 pipeline: 111 processors: 112 - jmespath: 113 query: "locations[?state == 'WA'].name | sort(@) | {Cities: join(', ', @)}" 114 ``` 115 116 </TabItem> 117 </Tabs> 118 119