|
|
@ -76,10 +76,10 @@ def to_json(a, *args, **kw):
|
|
|
|
return json.dumps(a, cls=AnsibleJSONEncoder, *args, **kw)
|
|
|
|
return json.dumps(a, cls=AnsibleJSONEncoder, *args, **kw)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def to_nice_json(a, indent=4, *args, **kw):
|
|
|
|
def to_nice_json(a, indent=4, sort_keys=True, *args, **kw):
|
|
|
|
'''Make verbose, human readable JSON'''
|
|
|
|
'''Make verbose, human readable JSON'''
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
return json.dumps(a, indent=indent, sort_keys=True, separators=(',', ': '), cls=AnsibleJSONEncoder, *args, **kw)
|
|
|
|
return json.dumps(a, indent=indent, sort_keys=sort_keys, separators=(',', ': '), cls=AnsibleJSONEncoder, *args, **kw)
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
# Fallback to the to_json filter
|
|
|
|
# Fallback to the to_json filter
|
|
|
|
display.warning(u'Unable to convert data using to_nice_json, falling back to to_json: %s' % to_text(e))
|
|
|
|
display.warning(u'Unable to convert data using to_nice_json, falling back to to_json: %s' % to_text(e))
|
|
|
|