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§
- IriConfused
With Prefix - An IRI cannot be written out because it would be read back as a compact IRI.
- Options
- Compaction options.
- Value
Hint - Describes a value to IRI compaction without materializing it.
Enums§
Traits§
- Compact
- Whole documents that can be compacted against a processed
@context. - Compact
Fragment - Document fragments that can be compacted against an active context.
- Compact
Indexed Fragment - Document fragments that carry an
@indexseparately from their own contents. - Embed
Context - Documents that a
@contextcan be embedded into.
Functions§
- compact_
iri - Compacts
varinto a term, compact IRI or relative IRI reference, without considering any value. - compact_
iri_ with - Compacts
varinto the term best suited to holdingvalue. - compact_
iri_ with_ hint - Compacts
varinto the term best suited to holding the valuehintdescribes. - 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
@typevalues 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§
- Compact
Document Result - Result of compacting a whole document.
- Compact
Fragment Result - Result of compacting a document fragment.