def compress_json(data):
    """ Take a Python data object. Convert to JSON and compress using lzstring """
    json_string = json.dumps(data).encode('utf-8', 'ignore').decode('utf-8')
    # JSON.parse() doesn't handle `NaN`, but it does handle `null`.
    json_string = json_string.replace('NaN', 'null');
    x = lzstring.LZString()
    return x.compressToBase64(json_string)
def compress_json ( data ) : json_string = json . dumps ( data ) . encode ( 'utf-8' , 'ignore' ) . decode ( 'utf-8' ) json_string = json_string . replace ( 'NaN' , 'null' ) ; x = lzstring . LZString ( ) return x . compressToBase64 ( json_string )
Take a Python data object. Convert to JSON and compress using lzstring