Skip to main content

Crate jsonld_compaction

Crate jsonld_compaction 

Source
Expand description

Implementation of the JSON-LD compaction algorithms.

Compaction turns an expanded JSON-LD document back into the terse, human-friendly shape described by a @context: IRIs become terms or compact IRIs, single-element arrays collapse, and value objects reduce to plain JSON scalars wherever the context makes that lossless.

Compact compacts a whole document (an ExpandedDocument or a FlattenedDocument) and embeds the @context used into the output. CompactFragment compacts a single object, node, list or collection against an already-processed active context, and is what the document-level algorithm recurses through.

This crate is the compaction half of the jsonld family; the jsonld crate re-exports it behind a processor API that also handles expansion, flattening and RDF serialization.

Structs§

IriConfusedWithPrefix
An IRI cannot be written out because it would be read back as a compact IRI.
Options
Compaction options.
ValueHint
Describes a value to IRI compaction without materializing it.

Enums§

Error
Error raised while compacting a document.
ValueKind
Kind of a value described by a ValueHint.

Traits§

Compact
Whole documents that can be compacted against a processed @context.
CompactFragment
Document fragments that can be compacted against an active context.
CompactIndexedFragment
Document fragments that carry an @index separately from their own contents.
EmbedContext
Documents that a @context can be embedded into.

Functions§

compact_iri
Compacts var into a term, compact IRI or relative IRI reference, without considering any value.
compact_iri_with
Compacts var into the term best suited to holding value.
compact_iri_with_hint
Compacts var into the term best suited to holding the value hint describes.
compact_node_reference
Compacts a node reference, a node object whose only entry is @id, against an active context in which the active property’s scoped context is already in force.
compact_value
Compacts a value object against an active context in which the active property’s scoped context is already in force, following the value compaction algorithm.
keyword_alias
Returns the key a keyword compacts to under the active context, which is either an alias the context defines for it or the keyword itself.
types_as_array
Checks whether the @type values of a node object are written as an array even when there is only one.
values_as_array
Checks whether the values of a property are written as an array even when there is only one.

Type Aliases§

CompactDocumentResult
Result of compacting a whole document.
CompactFragmentResult
Result of compacting a document fragment.