【发布时间】:2013-04-25 01:29:34
【问题描述】:
我刚刚意识到json.dumps() 在 JSON 对象中添加了空格
例如
{'duration': '02:55', 'name': 'flower', 'chg': 0}
如何删除空格以使 JSON 更紧凑并节省通过 HTTP 发送的字节?
如:
{'duration':'02:55','name':'flower','chg':0}
【问题讨论】:
-
Python 3.4 修复了这个问题:
Changed in version 3.4: Use (',', ': ') as default if indent is not None.docs.python.org/3/library/json.html#json.dump
标签: python json serialization