jsonld.expand()¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_
|
the JSON-LD input to expand. |
required | |
options
|
ExpandOptions | None
|
optional processing options; see Options below. |
None
|
on_property_dropped
|
OnPropertyDropped
|
handler called on every ignored property. |
noop
|
Returns:
| Type | Description |
|---|---|
|
the expanded JSON-LD output. |
Options¶
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).
processingMode
instance-attribute
¶
Either json-ld-1.0 or json-ld-1.1 (default: json-ld-1.1).
Example¶
Example expand.py
import json
from pyld import jsonld
doc = {
"@context": {
"name": "http://schema.org/name",
"homepage": {"@id": "http://schema.org/url", "@type": "@id"},
"image": {"@id": "http://schema.org/image", "@type": "@id"},
},
"image": "http://manu.sporny.org/images/manu.png",
"homepage": "http://manu.sporny.org/",
"name": "Manu Sporny",
}
expanded = jsonld.expand(doc)
print(json.dumps(expanded, indent=2))