import base64
import gzip
import json


def decode(value, decompress=False):
    """Decodes response from Base64 encoded string."""
    decoded = base64.b64decode(value)
    if decompress:
        decoded = gzip.decompress(decoded)
    return json.loads(decoded.decode())