filter "to_json" and double quotes

Hi !

I want to export YAML variable to JSON for use with jq tool but the last don’t like JSON sent by Ansible.
shell : ‘echo {{ var | to_json }} | jq’

For that work, I must quote keys and datas that seems the good way. See here : http://stackoverflow.com/questions/949449/json-spec-does-the-key-have-to-be-surrounded-with-quotes
Is there any possibility to do that with Ansible ?

Thanks,
Sylvain

I imagine that the problem is that you need to quote what is being echoed. Something like:

shell: echo ‘{{ var | to_json }}’ | jq

Oh yes, it was that !
I’ve forgotten that using shell module can eat quoting.

Thanks ! :slight_smile:

Sylvain