Skip to content

jsonld.to_rdf()

Parameters:

Name Type Description Default
input_

the JSON-LD input.

required
options ToRdfOptions | None

optional processing options; see Options below.

None

Returns:

Type Description

the resulting RDF dataset (or a serialization of it).

Options

base instance-attribute

base: str

The base IRI to use.

documentLoader instance-attribute

documentLoader: DocumentLoader | DocumentLoaderCallable

The document loader (default: the global default document loader).

extractAllScripts instance-attribute

extractAllScripts: bool

True to extract all JSON-LD script elements from HTML, False to extract just the first (default: True).

format instance-attribute

format: Literal['application/n-quads']

The format to use to output a string: application/n-quads for N-Quads.

processingMode instance-attribute

processingMode: Literal['json-ld-1.0', 'json-ld-1.1']

Either json-ld-1.0 or json-ld-1.1 (default: json-ld-1.1).

produceGeneralizedRdf instance-attribute

produceGeneralizedRdf: bool

True to output generalized RDF, False to produce only standard RDF (default: False).

rdfDirection instance-attribute

rdfDirection: Literal['i18n-datatype']

Only i18n-datatype supported.

Example

Example to_rdf.py

from pyld import jsonld

doc = {
    "@context": {
        "name": "http://schema.org/name",
    },
    "@id": "http://dbpedia.org/resource/Earth",
    "name": "Earth",
}

print(jsonld.to_rdf(doc, {"format": "application/n-quads"}))
Output
<http://dbpedia.org/resource/Earth> <http://schema.org/name> "Earth" .