mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 08:59:54 +03:00
parsers: Inline fp.read() of json.load in JSONParser
This enables upcoming inspection of the decoded data on string level, prior to parsing JSON.
This commit is contained in:
parent
1b23543ed1
commit
3d10d82d0e
|
@ -61,8 +61,8 @@ class JSONParser(BaseParser):
|
|||
encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET)
|
||||
|
||||
try:
|
||||
decoded_stream = codecs.getreader(encoding)(stream)
|
||||
return json.load(decoded_stream, parse_constant=parse_constant)
|
||||
decoded_string = codecs.getreader(encoding)(stream).read()
|
||||
return json.loads(decoded_string, parse_constant=parse_constant)
|
||||
except ValueError as exc:
|
||||
raise ParseError('JSON parse error - %s' % str(exc))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user