title: Count the numer of instance in an array using JMESPath
body: <p>In the example JSON at the bottom of this question, how can I count the number of key/value pairs in the array <code>"Tags"</code> using JMESPath?</p>
  
  <p>According to the <a href="http://jmespath.readthedocs.io/en/stable/specification.html#current-node" rel="noreferrer">JMESPath documentation</a>, I can do this using the <code>count()</code> function -</p>
  
  <blockquote>
    <p>For example, the following expression creates an array containing the total number of elements in the foo object followed by the value of foo["bar"].</p>
  </blockquote>
  
  <p>However, it seems that the documentation is incorrect.  Using the JMESPath website, the query <code>Reservations[].Instances[].[count(@), Tags]</code> yeilds the result <code>[ [ null ] ]</code>.  I then tested via the AWS command line and an error was returned -</p>
  
  <blockquote>
    <p>Unknown function: count()</p>
  </blockquote>
  
  <p>Is there actually a way of doing this using JMESPath?</p>
  
  <p>Example JSON -</p>
  
  <pre><code>{
      "Reservations": [
          {
              "Instances": [
                  {
                      "InstanceId": "i-asdf1234",
                      "InstanceName": "My Instance",
                      "Tags": [
                          {
                              "Value": "Value1",
                              "Key": "Key1"
                          },
                          {
                              "Value": "Value2",
                              "Key": "Key2"
                          },
                          {
                              "Value": "Value3",
                              "Key": "Key3"
                          },
                          {
                              "Value": "Value4",
                              "Key": "Key4"
                          }
                      ]
                  }
              ]
          }
      ]
  }
  </code></pre>