mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 04:50:12 +03:00
Provide an easy way to have JSON keys sorted.
This commit is contained in:
parent
b3af4d9fe7
commit
6bd2cb69f6
|
@ -51,6 +51,7 @@ class JSONRenderer(BaseRenderer):
|
||||||
format = 'json'
|
format = 'json'
|
||||||
encoder_class = encoders.JSONEncoder
|
encoder_class = encoders.JSONEncoder
|
||||||
ensure_ascii = True
|
ensure_ascii = True
|
||||||
|
sort_keys = False
|
||||||
|
|
||||||
# We don't set a charset because JSON is a binary encoding,
|
# We don't set a charset because JSON is a binary encoding,
|
||||||
# that can be encoded as utf-8, utf-16 or utf-32.
|
# that can be encoded as utf-8, utf-16 or utf-32.
|
||||||
|
@ -84,7 +85,8 @@ class JSONRenderer(BaseRenderer):
|
||||||
|
|
||||||
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,
|
||||||
|
sort_keys=self.sort_keys
|
||||||
)
|
)
|
||||||
|
|
||||||
# On python 2.x json.dumps() returns bytestrings if ensure_ascii=True,
|
# On python 2.x json.dumps() returns bytestrings if ensure_ascii=True,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user