Reputation: 6825
When I run Ansible debug
module and print out some variable, I get message that looks similar to JSON, but is not really JSON and can't be parsed into JSON directly. It looks like this:
ok: [zoo_01] => {
"msg": "Hostvars {u'zoo_01': {u'module_setup': True, u'ansible_distribution_version'...
When I replace all of the following, it becomes parsable as JSON
u' -> "
' -> "
True -> true
False -> false
None -> null
Is there any tool that can parse it as JSON and show me it's nice structure? I would like something like this: https://codebeautify.org/online-json-editor
Or maybe this format has a name?
Upvotes: 1
Views: 3261
Reputation: 68269
This is Python representation:
Use to_json
filter to get JSON output. Or var
instead of msg
:
- debug:
var: myvar
- debug:
msg: "My JSON {{ myvar | to_json }}"
Upvotes: 2