In some cases, you can only get rid of trailing spaces . Then you can use
json.dumps(separators=(',', ': '))
There is a space after : but not after,.
This is useful for delimiting your JSON files (in version control, such as git diff ), where some editors get rid of the trailing space, but python json.dump will add it back.
Note. This certainly does not answer the question from above, but I came here in search of this answer. I don't think it deserves its own QA, so I add it here.
Hugues Fontenelle Jan 26 '16 at 12:14 2016-01-26 12:14
source share