mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 04:50:12 +03:00
Update JSONParser decoding behavior
Allow to define a decoder class for the JSONParser.
This commit is contained in:
parent
cd4c389d1f
commit
1123bf1011
|
@ -53,6 +53,7 @@ class JSONParser(BaseParser):
|
|||
"""
|
||||
|
||||
media_type = 'application/json'
|
||||
decoder_class = json.JSONDecoder
|
||||
renderer_class = renderers.JSONRenderer
|
||||
|
||||
def parse(self, stream, media_type=None, parser_context=None):
|
||||
|
@ -64,7 +65,7 @@ class JSONParser(BaseParser):
|
|||
|
||||
try:
|
||||
data = stream.read().decode(encoding)
|
||||
return json.loads(data)
|
||||
return json.loads(data, cls=self.decoder_class)
|
||||
except ValueError as exc:
|
||||
raise ParseError('JSON parse error - %s' % six.text_type(exc))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user