Discussion:
[ansible-project] to_json uses single quotes
Barry Kaplan
2015-07-17 06:08:35 UTC
Permalink
I've seen one other post on this from 2014, but it did not really have
solution. Whenever I use
to_json the resulting json uses single quotes. Then when I later try to use
from_json it does
not parse.

Is anybody else experiencing this? Any known workarounds?
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/843424c0-585c-458d-ad0b-e9d6da8dd227%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Brian Coca
2015-07-17 13:18:10 UTC
Permalink
I normally use from_yaml as it is much more forgiving than from_json.
--
Brian Coca
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJ5XC8n5N%2BdAoh%2BfGGY95Sq4VZi0BB-K-A%2BCeDkxyqtjjXZM9g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Abhijit Menon-Sen
2015-07-17 13:06:22 UTC
Permalink
Whenever I use to_json the resulting json uses single quotes. Then
when I later try to use from_json it does not parse.
Could you provide more details, please? It worked in the simple case I
just tried:

$ ansible localhost -m debug -a "msg='{{ p|to_json }}'" --extra-vars @p.yml
localhost | success >> {
"msg": "[{\"foo\": 1, \"bar\": 2}, {\"buzh\": 42, \"barf\": 2}]"
}

-- Abhijit
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20150717130622.GA10756%40toroid.org.
For more options, visit https://groups.google.com/d/optout.
Barry Kaplan
2015-07-18 02:55:01 UTC
Permalink
Post by Abhijit Menon-Sen
Could you provide more details, please? It worked in the simple case I
localhost | success >> {
"msg": "[{\"foo\": 1, \"bar\": 2}, {\"buzh\": 42, \"barf\": 2}]"
}
-- Abhijit
I've been down this path also, and see just what you see. But when I store
that value (say
in consul to be used later) it actually stores the quoted quotes -- \" --
not the parsable json.

I'll build some simple examples that demonstrate my issues. Hopefully I'm
making some silly mistakes.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/45f5fd84-2b3b-40b9-a12a-4fec9eb15de8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...