Format JSON more efficiently. This can significantly reduce response sizes from the server.

This commit is contained in:
Dave Page 2017-01-06 14:09:36 +00:00
parent fe9bdc62a1
commit 1504d05cdd

View File

@ -55,7 +55,7 @@ def make_json_response(
doc['data'] = data
return Response(
response=json.dumps(doc, cls=DataTypeJSONEncoder),
response=json.dumps(doc, cls=DataTypeJSONEncoder, separators=(',',':')),
status=status,
mimetype="application/json",
headers=get_no_cache_header()
@ -65,7 +65,7 @@ def make_json_response(
def make_response(response=None, status=200):
"""Create a JSON response handled by the backbone models."""
return Response(
response=json.dumps(response, cls=DataTypeJSONEncoder),
response=json.dumps(response, cls=DataTypeJSONEncoder, separators=(',',':')),
status=status,
mimetype="application/json",
headers=get_no_cache_header()