Skip to content

Commit

Permalink
Merge 8bd5003 into 0481957
Browse files Browse the repository at this point in the history
  • Loading branch information
hubbyist committed Jan 12, 2015
2 parents 0481957 + 8bd5003 commit 541c1a4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions httpie/output/formatters/json.py
@@ -1,5 +1,6 @@
from __future__ import absolute_import
import json
import collections

from httpie.plugins import FormatterPlugin

Expand All @@ -12,15 +13,15 @@ class JSONFormatter(FormatterPlugin):
def format_body(self, body, mime):
if 'json' in mime:
try:
obj = json.loads(body)
obj = json.loads(body, object_pairs_hook=collections.OrderedDict)
except ValueError:
# Invalid JSON, ignore.
pass
else:
# Indent, sort keys by name, and avoid
# unicode escapes to improve readability.
body = json.dumps(obj,
sort_keys=True,
sort_keys=False,
ensure_ascii=False,
indent=DEFAULT_INDENT)
return body

0 comments on commit 541c1a4

Please sign in to comment.