title: ansible json_query multiple values
body: <p>From a prior <code>GET</code> api call in ansible I'm getting a json result back.</p>
  <p>The api call would look something like this:</p>
  <pre><code>- name: Refresh Datadog monitors list
    uri:
      url: http://my.api.com
      return_content: yes
      method: GET
      status_code: 200
      headers:
        Content-Type: &quot;application/json&quot;
    register: results
  </code></pre>
  <p>The result looks something like this (dummy data):</p>
  <pre><code>[{
      &quot;name&quot;: &quot;bob&quot;,
      &quot;id&quot;: 13590804,
      &quot;colour&quot;: &quot;blue&quot;,
      &quot;created&quot;: &quot;2019-11-21T07:41:33.148976+00:00&quot;,
      &quot;modified&quot;: &quot;2019-11-21T07:41:33.148976+00:00&quot;,
      &quot;overall_state_modified&quot;: &quot;2019-11-25T06:45:08+00:00&quot;,
      &quot;overall_state&quot;: &quot;OK&quot;
  },
  {
      &quot;name&quot;: &quot;john&quot;,
      &quot;id&quot;: 123124515,
      &quot;colour&quot;: &quot;green&quot;,
      &quot;created&quot;: &quot;2019-11-21T07:41:33.148976+00:00&quot;,
      &quot;modified&quot;: &quot;2019-11-21T07:41:33.148976+00:00&quot;,
      &quot;overall_state_modified&quot;: &quot;2019-11-25T06:45:08+00:00&quot;,
      &quot;overall_state&quot;: &quot;OK&quot;
  },
  {
      &quot;name&quot;: &quot;carl&quot;,
      &quot;id&quot;: 3252532,
      &quot;colour&quot;: &quot;orange&quot;,
      &quot;created&quot;: &quot;2019-11-21T07:41:33.148976+00:00&quot;,
      &quot;modified&quot;: &quot;2019-11-21T07:41:33.148976+00:00&quot;,
      &quot;overall_state_modified&quot;: &quot;2019-11-25T06:45:08+00:00&quot;,
      &quot;overall_state&quot;: &quot;OK&quot;
  },
  {
      &quot;name&quot;: &quot;louis&quot;,
      &quot;id&quot;: 5675467,
      &quot;colour&quot;: &quot;purple&quot;,
      &quot;created&quot;: &quot;2019-11-21T07:41:33.148976+00:00&quot;,
      &quot;modified&quot;: &quot;2019-11-21T07:41:33.148976+00:00&quot;,
      &quot;overall_state_modified&quot;: &quot;2019-11-25T06:45:08+00:00&quot;,
      &quot;overall_state&quot;: &quot;OK&quot;
  }]
  </code></pre>
  <p>In a subsequent step I'm looking to do extract just two values from the json so that it looks something like:</p>
  <pre><code>[{
          &quot;name&quot;: &quot;bob&quot;,
          &quot;id&quot;: 13590804
      },
      {
          &quot;name&quot;: &quot;john&quot;,
          &quot;id&quot;: 123124515
      },
      {
          &quot;name&quot;: &quot;carl&quot;,
          &quot;id&quot;: 3252532
      },
      {
          &quot;name&quot;: &quot;louis&quot;,
          &quot;id&quot;: 5675467
      }
  ]
  </code></pre>
  <p>I've tried multiple iterations from different sources to try and get this result such as:</p>
  <pre><code>- name: &quot;Display all id's with names&quot;
    debug: msg = &quot;{{ results | json_query '[id, names]')}}&quot;
  </code></pre>
  <p>and</p>
  <pre><code>- name: &quot;Display all id's with names&quot;
    debug: msg = &quot;{{ results | json_query '[*][id, names]')}}&quot;
  </code></pre>
  <p>I can appreciate that there's a gap in my knowledge of jmespath, but the documentation is a bit overwhelming and I'm unable to find the exact solution.</p>