def flatten_json(d, new={}):
    """ Flattens a nested dictionary. """
    for k, v in d.items():
        if isinstance(v, dict):
            flatten_json(v, new)
        else:
            new[k] = v
    return new