Skip to content

jsonld.normalize()

Parameters:

Name Type Description Default
input_

the JSON-LD input to normalize.

required
options NormalizeOptions | None

optional processing options; see Options below.

None

Returns:

Type Description

the normalized output.

Options

algorithm instance-attribute

algorithm: Literal['URDNA2015', 'URGNA2012']

The algorithm to use (default: URGNA2012).

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: False).

format instance-attribute

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

The format if output is a string: application/n-quads for N-Quads.

inputFormat instance-attribute

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

The format if input is not JSON-LD: 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).

Example

Example normalize.py

from pyld import jsonld

doc = {
    "@type": "http://schema.org/Person",
    "http://schema.org/name": "Manu Sporny",
    "http://schema.org/url": {"@id": "http://manu.sporny.org/"},
    "http://schema.org/image": {
        "@id": "http://manu.sporny.org/images/manu.png"
    },
}

normalized = jsonld.normalize(
    doc,
    {"algorithm": "URDNA2015", "format": "application/n-quads"},
)

print(normalized)
Output
_:c14n0 <http://schema.org/image> <http://manu.sporny.org/images/manu.png> .
_:c14n0 <http://schema.org/name> "Manu Sporny" .
_:c14n0 <http://schema.org/url> <http://manu.sporny.org/> .
_:c14n0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .