mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 03:23:59 +03:00
Fix key ordering in json. (sort if it's a sorted dictc representation, or not otherwise)
This commit is contained in:
parent
648d2be29b
commit
db6b5a990b
|
@ -54,7 +54,6 @@ class JSONRenderer(BaseRenderer):
|
|||
# E.g. If we're being called by the BrowseableAPIRenderer.
|
||||
renderer_context = renderer_context or {}
|
||||
indent = renderer_context.get('indent', None)
|
||||
sort_keys = indent and True or False
|
||||
|
||||
if accepted_media_type:
|
||||
# If the media type looks like 'application/json; indent=4',
|
||||
|
@ -63,12 +62,10 @@ class JSONRenderer(BaseRenderer):
|
|||
indent = params.get('indent', indent)
|
||||
try:
|
||||
indent = max(min(int(indent), 8), 0)
|
||||
sort_keys = True
|
||||
except (ValueError, TypeError):
|
||||
indent = None
|
||||
|
||||
return json.dumps(data, cls=self.encoder_class,
|
||||
indent=indent, sort_keys=sort_keys)
|
||||
return json.dumps(data, cls=self.encoder_class, indent=indent)
|
||||
|
||||
|
||||
class JSONPRenderer(JSONRenderer):
|
||||
|
|
Loading…
Reference in New Issue
Block a user