Exemple #1
0
def json_to_rdf(json_in: jsonasobj.JsonObj, schema_uri: str) -> Graph:
    """ Use the jsonld processor to convert the json into an RDF graph
    :param json_in:
    :param schema_uri: the base URI of the schema file
    :return: RDF graph
    """
    json_in['@context'] = schema_uri + ('/' if schema_uri[-1] not in ['/', '#'] else '') + 'context.json'
    normalized = jsonld.normalize(json_in._as_json_obj(), {'format': 'application/nquads', 'algorithm': 'URDNA2015'})
    g = Graph()
    g.parse(data=prefixes, format="turtle")
    g.parse(data=normalized, format="turtle")
    return g