mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge branch 'alozovskoy-alozovskoy-debug-ascii-patch' into devel
This commit is contained in:
commit
bae73e5793
1 changed files with 8 additions and 3 deletions
|
@ -207,10 +207,15 @@ def jsonify(result, format=False):
|
||||||
for key, value in result2.items():
|
for key, value in result2.items():
|
||||||
if type(value) is str:
|
if type(value) is str:
|
||||||
result2[key] = value.decode('utf-8', 'ignore')
|
result2[key] = value.decode('utf-8', 'ignore')
|
||||||
|
|
||||||
|
indent = None
|
||||||
if format:
|
if format:
|
||||||
return json.dumps(result2, sort_keys=True, indent=4)
|
indent = 4
|
||||||
else:
|
|
||||||
return json.dumps(result2, sort_keys=True)
|
try:
|
||||||
|
return json.dumps(result2, sort_keys=True, indent=indent, ensure_ascii=False)
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
return json.dumps(result2, sort_keys=True, indent=indent)
|
||||||
|
|
||||||
def write_tree_file(tree, hostname, buf):
|
def write_tree_file(tree, hostname, buf):
|
||||||
''' write something into treedir/hostname '''
|
''' write something into treedir/hostname '''
|
||||||
|
|
Loading…
Reference in a new issue