Daniele B Daniele B - 10 months ago 57
JSON Question

Python - json without whitespaces

I just realized that

adds spaces in the JSON object


{'duration': '02:55', 'name': 'flower', 'chg': 0}

how can remove the spaces in order to make the JSON more compact and save bytes to be sent via HTTP?

such as:


Answer Source
json.dumps(separators=(',', ':'))