Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 7c0411c

Browse files
committed
yet another fix for unicode/utf8 returned JSON data
1 parent 99005c1 commit 7c0411c

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

CloudFlare/cloudflare.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def _raw(self, method, headers, parts,
278278
if response_type == 'application/json':
279279
# API says it's JSON; so it better be parsable as JSON
280280
try:
281-
response_data = json.loads(response_data)
281+
response_data = json.loads(response_data.decode('utf-8'))
282282
except ValueError:
283283
if response_data == '':
284284
# This should really be 'null' but it isn't. Even then, it's wrong!

cli4/cli4.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,13 @@ def cli4(args):
288288
else:
289289
# anything more complex (dict, list, etc) should be dumped as JSON/YAML
290290
if output == 'json':
291-
sys.stdout.write(json.dumps(results, indent=4, sort_keys=True) + '\n')
292291
# json.dumps(results, sys.stdout, indent=4, sort_keys=True)
293292
# sys.stdout.write('\n')
293+
# sys.stdout.write(json.dumps(results, indent=4, sort_keys=True) + '\n')
294+
try:
295+
print(json.dumps(results, indent=4, sort_keys=True, ensure_ascii=False, encoding='utf8'))
296+
except TypeError as e:
297+
print(json.dumps(results, indent=4, sort_keys=True, ensure_ascii=False))
294298
if output == 'yaml':
295299
sys.stdout.write(yaml.safe_dump(results))
296300

0 commit comments

Comments
 (0)