JSON.LD.Compaction (JSON-LD.ex v1.0.0)

View Source

Implementation of the JSON-LD 1.1 Compaction Algorithms.

https://www.w3.org/TR/json-ld11-api/#compaction-algorithm

Summary

Functions

compact(element, active_context, active_property, options, compact_arrays \\ false, ordered \\ false)

compact_iri(var, active_context, options, value \\ nil, vocab \\ true, reverse \\ false)

@spec compact_iri(
  any(),
  JSON.LD.Context.t(),
  JSON.LD.Options.t(),
  any() | nil,
  boolean(),
  boolean()
) ::
  any() | nil

IRI Compaction

See https://www.w3.org/TR/json-ld11-api/#iri-compaction

compact_value(value, active_context, active_property, options)

@spec compact_value(any(), JSON.LD.Context.t(), String.t(), JSON.LD.Options.t()) ::
  any()

Value Compaction

Details at https://www.w3.org/TR/json-ld-api/#value-compaction

select_term(map, var, containers, type_language, preferred_values)

@spec select_term(JSON.LD.Context.t(), String.t(), [String.t()], String.t(), [
  String.t()
]) ::
  String.t() | nil

Term Selection

Note: Other than specified in W3C spec we assume here that the inverse context is already created, since we don't want to return an updated context. Effectively an inverse context is never needed in the only place where this function is used.

https://www.w3.org/TR/json-ld11-api/#term-selection