package rdf_json_ld

  1. Overview
  2. Docs

JSON-LD API.

Only minimum functions to communicate with JSON-LD are implemented, i.e. context processing, expansion, deserialization and serialization.

Use of JSON-LD should be avoided when possible.

val init_ctx : Iri.t -> Expand.ctx

Initialize an expansion context from the given base IRI.

val ctx_of_options : T.options -> Iri.t -> Expand.ctx Lwt.t

Same as init_ctx but will use the provided T.options to initialize a context. This includes downloading and processing an optional "expand context".

val expansion : T.options -> ?frame_expansion:bool -> Expand.ctx -> J.json -> Iri.t -> J.json Lwt.t

expansion options context json base expands the given json value in context, with base IRI, honouring options. Optional argument frame_expansion is supposed to work as specified here (default is false).

val to_rdf : T.options -> J.json -> Rdf.Graph.graph -> (Rdf.Ds.dataset * Iri.t option) Lwt.t

to_rdf options json graph builds a context from options, expands the json value (using graph name as base IRI), then applies the node map generation and JSON-LD to RDF algorithms to build the returned dataset. The provided graph is the default graph of the returned dataset. The function also returns the optional root IRI if there is only one root object and it has an @id.

val from_rdf : T.options -> Rdf.Ds.dataset -> J.json

from_rdf options dataset serializes the given dataset to a JSON-LD value, honouring options. Beware that the specified RDF to JSON-LD algorithm is not implemented, but a simpler version returning some flat (but correct) JSON-LD.

val from_rdf_root : T.options -> Rdf.Graph.graph -> Rdf.Term.term -> J.json

from_rdf_root options graph root serializes the given graph to a JSON-LD value, with a single object starting from root term, honouring options. Beware that the specified RDF to JSON-LD algorithm is not implemented, but a simpler version returning some flat (but correct) JSON-LD. Lists are represented using json list, though.

OCaml

Innovation. Community. Security.