(20241203) Minor upgrades.
This commit is contained in:
@@ -136,17 +136,22 @@ class AuthDetailsIncompleteException(Exception):
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
async def make_ordered_json(json_data, http_code = 200):
|
||||
async def make_ordered_json(
|
||||
json_data,
|
||||
no_space = True,
|
||||
http_code = 200
|
||||
):
|
||||
|
||||
"""
|
||||
Quart sorts the fields of a dict when converting to a JSON response. Here we are manually making the response when
|
||||
the sequence of the fields is sensitive.
|
||||
:param json_data: The data (dict, list, etc.) to be converted to a JSON string.
|
||||
:param no_space: Set this to True to remove all excess white spaces from the JSON string. Saves bandwidth.
|
||||
:param http_code: The HTTP status code you want to send with the response.
|
||||
:return: The JSON-ified response such that the sequence of the fields is maintained.
|
||||
"""
|
||||
|
||||
response = await make_response(json.to_string(json_data, no_space = True), http_code)
|
||||
response = await make_response(json.to_string(json_data, no_space = no_space), http_code)
|
||||
response.headers["Content-Type"] = "application/json"
|
||||
return response
|
||||
|
||||
|
||||
Reference in New Issue
Block a user