def fetch_json(uri, path=''):
    import json
    import urllib.request

    with urllib.request.urlopen(uri) as response:
        value = json.load(response)

    if path:
        for key in path.split('.'):
            value = value.get(key) if isinstance(value, dict) else None
            if value is None:
                return None

    return value

def valentina_extension_init(db):
    valentina.create_procedure('fetch_json', fetch_json)
