github.com/Jeffail/benthos/v3@v3.65.0/website/docs/components/conditions/jmespath.md (about)

     1  ---
     2  title: jmespath
     3  type: condition
     4  status: stable
     5  ---
     6  
     7  <!--
     8       THIS FILE IS AUTOGENERATED!
     9  
    10       To make changes please edit the contents of:
    11       lib/condition/jmespath.go
    12  -->
    13  
    14  import Tabs from '@theme/Tabs';
    15  import TabItem from '@theme/TabItem';
    16  
    17  
    18  Executes a JMESPath query on JSON payloads, expecting a boolean result. If the
    19  result of the query is true then the condition passes, otherwise it does not.
    20  
    21  
    22  <Tabs defaultValue="common" values={[
    23    { label: 'Common', value: 'common', },
    24    { label: 'Advanced', value: 'advanced', },
    25  ]}>
    26  
    27  <TabItem value="common">
    28  
    29  ```yaml
    30  # Common config fields, showing default values
    31  jmespath:
    32    query: ""
    33  ```
    34  
    35  </TabItem>
    36  <TabItem value="advanced">
    37  
    38  ```yaml
    39  # All config fields, showing default values
    40  jmespath:
    41    query: ""
    42    part: 0
    43  ```
    44  
    45  </TabItem>
    46  </Tabs>
    47  
    48  Please refer to the [JMESPath website](http://jmespath.org/) for information and
    49  tutorials regarding the syntax of expressions.
    50  
    51  ## Fields
    52  
    53  ### `query`
    54  
    55  A [JMESPath](http://jmespath.org/) query.
    56  
    57  
    58  Type: `string`  
    59  Default: `""`  
    60  
    61  ```yaml
    62  # Examples
    63  
    64  query: foo == 'bar'
    65  
    66  query: length(doc.urls) > `0`
    67  ```
    68  
    69  ### `part`
    70  
    71  The index of a message within a batch to test the condition against. This
    72  field is only applicable when batching messages
    73  [at the input level](/docs/configuration/batching).
    74  
    75  Indexes can be negative, and if so the part will be selected from the end
    76  counting backwards starting from -1.
    77  
    78  
    79  Type: `number`  
    80  Default: `0`  
    81  
    82  ## Examples
    83  
    84  With the following config:
    85  
    86  ``` yaml
    87  jmespath:
    88    query: a == 'foo'
    89  ```
    90  
    91  If the initial jmespaths of part 0 were:
    92  
    93  ``` json
    94  {
    95  	"a": "foo"
    96  }
    97  ```
    98  
    99  Then the condition would pass.
   100  
   101  JMESPath is traditionally used for mutating JSON, in order to do this please
   102  instead use the [`jmespath`](/docs/components/processors/jmespath)
   103  processor.
   104