From 963b2746f55c5d94c9a81647e5840b98882ea9b8 Mon Sep 17 00:00:00 2001 From: Jakub Roztocil Date: Fri, 1 Jul 2016 18:57:13 +0200 Subject: [PATCH] Be more liberal when detecting JSON in the formatter Closes #485 --- httpie/output/formatters/json.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/httpie/output/formatters/json.py b/httpie/output/formatters/json.py index 64b15f0e..5a3e9bc9 100644 --- a/httpie/output/formatters/json.py +++ b/httpie/output/formatters/json.py @@ -10,7 +10,13 @@ DEFAULT_INDENT = 4 class JSONFormatter(FormatterPlugin): def format_body(self, body, mime): - if 'json' in mime or self.kwargs['explicit_json']: + maybe_json = [ + 'json', + 'javascript', + 'text', + ] + if (any(token in mime for token in maybe_json) or + self.kwargs['explicit_json']): try: obj = json.loads(body) except ValueError: