How to dump compressed strings in json? How to dump compressed strings in json? json json

How to dump compressed strings in json?


You could first base64 encode it to get this to work. It will add some size to the string but probably less than you saved by compressing it first:

data['extras'] = base64.b64encode(zlib.compress("My string".encode("utf-8")))