title: Ansible unable to convert string to dictionary from the stdout_lines
body: <p>I am trying to get the "count" value from the dictionary </p>
  
  <p>"{ \"_id\" : ObjectId(\"5d3a1643c43c898d01a3c740\"), \"count\" : 2 }"</p>
  
  <p>present at the last element of the ansible stdout_lines.</p>
  
  <pre><code>TASK [version_update : debug] ******************************************************************************************************************************************
  ok: [192.168.27.125] =&gt; {
      "count_info.stdout": "MongoDB shell version v4.0.6\nconnecting to: mongodb://127.0.0.1:27017/configure-db?gssapiServiceName=mongodb\nImplicit session: session { \"id\" : UUID(\"4bfad3ba-981f-47de-86f9-a1fadbe28e12\") }\nMongoDB server version: 4.0.6\n{ \"_id\" : ObjectId(\"5d3a1643c43c898d01a3c740\"), \"count\" : 2 }"
  }
  
  TASK [version_update : debug] ******************************************************************************************************************************************
  ok: [192.168.27.125] =&gt; {
      "count_info.stdout_lines": [
          "MongoDB shell version v4.0.6",
          "connecting to: mongodb://127.0.0.1:27017/configure-db?gssapiServiceName=mongodb",
          "Implicit session: session { \"id\" : UUID(\"4bfad3ba-981f-47de-86f9-a1fadbe28e12\") }",
          "MongoDB server version: 4.0.6",
          "{ \"_id\" : ObjectId(\"5d3a1643c43c898d01a3c740\"), \"count\" : 2 }"
      ]
  }
  </code></pre>
  
  <p>I tried the following two ways but not successful.</p>
  
  <pre><code>- debug:
      msg: "{{ (count_info.stdout_lines[-1] | from_json).count }}"
  
  - name: count value
    debug:
      msg: "{{ count_info.stdout_lines[-1] | json_query('count') }}"
  </code></pre>
  
  <p>Error log:</p>
  
  <pre><code>TASK [version_update : debug] ******************************************************************************************************************************************
  fatal: [192.168.27.125]: FAILED! =&gt; {"msg": "the field 'args' has an invalid value ({u'msg': u'{{ (count_info.stdout_lines[-1] | from_json).count }}'}), and could not be converted to an dict.The error was: No JSON object could be decoded\n\nThe error appears to have been in '/home/admin/playbook-3/roles/version_update/tasks/version_update.yml': line 73, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- debug:\n  ^ here\n"}
          to retry, use: --limit @/home/admin/playbook-3/version_update.retry
  
  TASK [version_update : count value] ************************************************************************************************************************************
  ok: [192.168.27.125] =&gt; {
      "msg": ""
  }
  </code></pre>