def unserialize_data(data, compression=False, encryption=False):
try:<EOL><INDENT>if encryption:<EOL><INDENT>data = encryption.decrypt(data)<EOL><DEDENT><DEDENT>except Exception as err:<EOL><INDENT>logger.error("<STR_LIT>" + str(err))<EOL>message = False<EOL><DEDENT>try:<EOL><INDENT>if compression:<EOL><INDENT>data = binascii.a2b_base64(data)<EOL>data = zlib.decompress(data)<EOL>message = json.loads(data)<EOL><DEDENT><DEDENT>except Exception as err:<EOL><INDENT>logger.error("<STR_LIT>" + str(err))<EOL>message = False<EOL><DEDENT>decoded_message = data.decode()<EOL>if not encryption and not compression:<EOL><INDENT>message = json.loads(decoded_message)<EOL><DEDENT>return message<EOL>
Unserializes the packet data and converts it from json format to normal
    Python datatypes.

    If you choose to enable encryption and/or compression when serializing
    data, you MUST enable the same options when unserializing data.

    Args:
      data (str): The raw, serialized packet data delivered from the transport
        protocol.
      compression (boolean): True or False value on whether or not to
        uncompress the serialized data.
      encryption (rsa.encryption): An encryption instance used to decrypt the
        message if encryption is desired.

    Returns:
      The message unserialized in normal Python datatypes.