import json


def retrieve_history(dataset):
    """
    Retrieve history_json field from NetCDF dataset, if it exists

    Parameters
    ----------
    dataset : netCDF4.Dataset
        NetCDF Dataset representing a single granule

    Returns
    -------
    dict
        history_json field
    """
    if 'history_json' not in dataset.ncattrs():
        return []
    history_json = dataset.getncattr('history_json')
    return json.loads(history_json)