title: Strange behavior about 'to_json' filter in ansible
body: <p>See example:</p>
  <pre class="lang-yaml prettyprint-override"><code>- hosts: localhost
    vars:
      a: &quot;stackoverflow&quot;
    tasks:
    - name: &quot;print a&quot;
      debug:
        msg: &quot;-d '{{a|to_json}}' -s '{{a|to_json}}'&quot;
  </code></pre>
  <p><strong>Expect output:</strong></p>
  <pre><code>&quot;msg&quot;: &quot;-d '\&quot;stackoverflow\&quot;' -s '\&quot;stackoverflow\&quot;'&quot;
  </code></pre>
  <p><strong>In fact</strong></p>
  <pre><code>&quot;msg&quot;: &quot;-d '\&quot;stackoverflow\&quot; -s \&quot;stackoverflow\&quot;'&quot;
  </code></pre>
  <p>How can i solve it?</p>