title: Ansible: Register variable when JSON value equals
body: <p>I'm calling a webservice and returning some JSON. I want to conditionally run a subsequent task, based on whether a particular <code>name</code> value is found.</p>
  
  <p>For example, set a value <code>nameExists</code> if and only if the <code>values</code> array contains a <code>name</code> field of <code>myDemo</code>. So in this case, <code>nameExists</code> would be defined:</p>
  
  <pre><code>...
  "failed": false,
  "json": {
    "values": [{
      "id": "1234",
      "name": "myDemo"
    },
    {
      "id": "6789",
      "name": "myDemo2"
    }]
  },
  "msg": "OK (100 bytes)"
  ...
  </code></pre>
  
  <p>Here's what I'm currently trying:</p>
  
  <pre><code># Call API
  - name: Call API
    uri:
      url: myURL
      method: POST
    register: apiCheckResult
  
  - name: Debug Auto tags
    debug:
      msg: "{{ item.name }}"
    loop: "{{ apiCheckResult.json['values'] }}"
    when: item.name == "myDemo"
    register: tagExists
  </code></pre>
  
  <p>This works, in a way, but it gives me the full JSON output, all I need is a true / false.</p>
  
  <p>Am I on the right track or is there a better way to achieve this? </p>