zoukankan      html  css  js  c++  java
  • 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.
  • 相关阅读:
    14-快速排序
    linux上挂在windows的共享文件系统,大小写不敏感
    【mount】linux挂共享盘
    监控windows服务或者进程
    自定义时间间隔
    示例
    filebeat
    kafka
    文档碎片
    简单DOM操作
  • 原文地址:https://www.cnblogs.com/sidianok/p/11556989.html
Copyright © 2011-2022 走看看