Skip to main content

Crate jsonld_expansion

Crate jsonld_expansion 

Source
Expand description

Implementation of the JSON-LD 1.1 Expansion algorithm.

Expansion rewrites a JSON-LD document into a regular form: terms and compact IRIs become full IRIs, the defaults a context sets (@base, @vocab, @language…) are applied to every value, and the @context entries themselves disappear. It is the first step of almost every other JSON-LD algorithm, since it removes the many ways the syntax offers to say the same thing.

The algorithm operates on the JSON syntax tree of the jstrict crate and produces the ExpandedDocument type of the jsonld-core crate.

§Usage

Expansion is exposed by the Expand trait, implemented for jstrict::Value (a parsed JSON document) and for RemoteDocument (a parsed JSON document along with the URL it comes from, used to resolve relative IRI references).

Most users will not depend on this crate directly but on the jsonld crate, which re-exports Expand next to the other JSON-LD algorithms.

Structs§

Context
Active context: everything the algorithms need to expand or compact against the current scope.
Environment
Vocabulary, loader and warning handler an algorithm runs against.
ExpandedDocument
Result of the document expansion algorithm: a set of (indexed) objects.
NotALiteral
Error raised when value expansion is asked to expand something that is not a JSON scalar, such as an array or an object.
Options
Expansion options.
Policy
Key expansion policy.
RemoteDocument
Remote document.

Enums§

Action
How strictly to treat a term whose expansion is questionable.
Error
Error raised while expanding a document.
Expanded
Result of expanding a fragment of a JSON-LD document.
IntoIter
Owning iterator over the objects of an expansion result.
InvalidValue
Error raised while expanding a value object, a map with an @value entry.
Iter
Iterator over the objects of an expansion result.
LiteralExpansionError
Error raised while expanding a scalar into a literal or a node reference.
SliceExpansionError
Error of expand_slice.
Warning
Warning raised while expanding a document.

Traits§

Expand
Document expansion.
Loader
Document loader.
WarningHandler
Handler for the warnings emitted while expanding a JSON-LD document.

Functions§

expand_slice
Expands the JSON-LD document whose JSON text is bytes.

Type Aliases§

ExpansionResult
Result of a document expansion, where E is the error type of the document loader used to fetch the remote contexts.