mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 04:50:12 +03:00
sort keys when output is a dictonary
This commit is contained in:
parent
d2286ba658
commit
89fa0d53cc
|
@ -99,6 +99,13 @@ class JSONRenderer(BaseRenderer):
|
||||||
else:
|
else:
|
||||||
separators = INDENT_SEPARATORS
|
separators = INDENT_SEPARATORS
|
||||||
|
|
||||||
|
if type(data) is dict:
|
||||||
|
ret = json.dumps(
|
||||||
|
data, cls=self.encoder_class,
|
||||||
|
indent=indent, ensure_ascii=self.ensure_ascii,
|
||||||
|
separators=separators, sort_keys=True
|
||||||
|
)
|
||||||
|
else:
|
||||||
ret = json.dumps(
|
ret = json.dumps(
|
||||||
data, cls=self.encoder_class,
|
data, cls=self.encoder_class,
|
||||||
indent=indent, ensure_ascii=self.ensure_ascii,
|
indent=indent, ensure_ascii=self.ensure_ascii,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user