pub fn compact_value<N>(
vocabulary: &N,
value: &Value<N::Iri>,
index: Option<&str>,
active_context: &Context<N::Iri, N::BlankId>,
active_property: Option<&str>,
options: Options,
) -> Result<Value, IriConfusedWithPrefix>Expand description
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.
Reduces the value object to a bare JSON scalar whenever the active
property’s type, language and direction mappings already say everything
the value object spells out — a typed literal under a term with that type
mapping, a language-tagged string under a term with that language, a
@json literal under a @json-typed term. Otherwise rebuilds it as an
object keyed by the active context’s aliases of @value, @type,
@language, @direction and @index, compacting a datatype IRI with
vocab set to true.
active_property is the compacted term the value is written under, as
compact_iri_with or
compact_iri_with_hint selected it, or
None at the top level. When that term defines a scoped @context,
active_context must be the result of processing it on top of the
context the term was selected in, as the compaction algorithm does before
calling this; when it does not, active_context is that context itself.
index is the @index the value was reached through. It is dropped when
the active property’s container mapping includes @index, because it has
already become the enclosing map’s key.
This is synchronous and needs no loader. Only options.processing_mode
is read.
§Errors
Returns IriConfusedWithPrefix when the value’s datatype IRI can only
be written out in full and would then be read back as a compact IRI.