import json


def decode2(data, default=None):
    """
    Load json data from a string. Return a default value of {} if the data is invalid.
    """
    if default is None:
        default = {}
    try:
        return json.loads(data)
    except ValueError:
        return default