Django返回数据json.dumps相关设置。

json.dump(
    obj,
    fp,
    *,
    skipkeys=False,
    ensure_ascii=True,
    check_circular=True,
    allow_nan=True,
    cls=None,
    indent=None,
    separators=None,
    default=None,
    sort_keys=False,
    **kw,
)

If specified, ``separators`` should be an ``(item_separator, key_separator)``
tuple.  The default is ``(', ', ': ')`` if *indent* is ``None`` and
``(',', ': ')`` otherwise.  To get the most compact JSON representation,
you should specify ``(',', ':')`` to eliminate whitespace.

separators默认多分隔符为(', ', ': '),里面带有空格,在返回前段多时候,如果空字符带上,会消耗传输速度。

indent参数可以在调试模式设置为4,这样显示多返回数据看起来比较好

ensure_ascii设置为False,返回给前段中文不会转化为asc。

sort_keys参数,排序选项

ascii设置为False,返回给前段中文不会转化为asc。
[Ascii shèzhì wèi False, fǎnhuí gěi qiánduàn zhōngwén bù huì zhuǎnhuà wéi asc.]
ascii set to False, returns to the preceding Chinese not translate into asc.
posted @ 2019-09-20 14:35  就是想学习  阅读(1004)  评论(0编辑  收藏  举报