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?
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
I normally use from_yaml as it is much more forgiving than from_json.
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.