import json


def load_id_json(json_path, add_id=False, id_field_name='id'):
    """ Return a list of the objects in the json file.
    If the JSON is a dictionary, will insert the object key value
    into the object's 'id' field.
    """
    if not add_id:
        return [item for eid, item in json.load(open(json_path)).items()]

    data = json.load(open(json_path))
    if isinstance(data, list):
        return data

    items = []
    for eid, item in data.items():
        item[id_field_name] = eid
        items.append(item)
    return items