Be more liberal when detecting JSON in the formatter

Closes #485
This commit is contained in:
Jakub Roztocil 2016-07-01 18:57:13 +02:00
parent 098257c0be
commit 963b2746f5

View File

@ -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: