Untitled

mail@pastecode.io avatar
unknown
python
a year ago
375 B
4
Indexable
Never
import json, zlib
from base64 import b64encode, b64decode

def compress_json(json_data):
    compressed = zlib.compress(json.dumps(json_data).encode('utf-8'))
    compressed_b64 = b64encode(compressed).decode('utf-8')
    return compressed_b64

def decompress_json(compressed_b64):
    ld = json.loads(zlib.decompress(b64decode(compressed_b64)).decode('utf-8'))
    return ld