def getpath(d, json_path, default=None, sep='.'):
    """Gets a value nested in dictionaries containing dictionaries.
    Returns the default if any key in the path doesn't exist.
    """
    for key in json_path.split(sep):
        try:
            d = d[key]
        except (KeyError, TypeError):
            return default
    return d
