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
¶
The algorithm to use (default: URGNA2012).
documentLoader
instance-attribute
¶
The document loader (default: the global default document loader).
extractAllScripts
instance-attribute
¶
True to extract all JSON-LD script elements from HTML, False to extract just the first (default: False).
format
instance-attribute
¶
The format if output is a string: application/n-quads for N-Quads.
inputFormat
instance-attribute
¶
The format if input is not JSON-LD: application/n-quads for N-Quads.
processingMode
instance-attribute
¶
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)