mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 17:09:59 +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)
|
encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
decoded_stream = codecs.getreader(encoding)(stream)
|
decoded_string = codecs.getreader(encoding)(stream).read()
|
||||||
return json.load(decoded_stream, parse_constant=parse_constant)
|
return json.loads(decoded_string, parse_constant=parse_constant)
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
raise ParseError('JSON parse error - %s' % str(exc))
|
raise ParseError('JSON parse error - %s' % str(exc))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user