View Source JSON.LD.Encoder (JSON-LD.ex v0.3.8)

An encoder for JSON-LD serializations of RDF.ex data structures.

As for all encoders of RDF.Serialization.Formats, you normally won't use these functions directly, but via one of the write_ functions on the JSON.LD format module or the generic RDF.Serialization module.

Options

  • :context: When a context map or remote context URL string is given, compaction is performed using this context
  • :base: : Allows to specify a base URI to be used during compaction (only when :context is provided). Default is the base IRI of the encoded graph or if none present or in case of encoded datasets the RDF.default_base_iri/0.
  • :use_native_types: If this flag is set to true, RDF literals with a datatype IRI that equals xsd:integer or xsd:double are converted to a JSON numbers and RDF literals with a datatype IRI that equals xsd:boolean are converted to true or false based on their lexical form. (default: false)
  • :use_rdf_type: Unless this flag is set to true, rdf:type predicates will be serialized as @type as long as the associated object is either an IRI or blank node identifier. (default: false)

The given options are also passed through to Jason.encode/2, so you can also provide any the options this function supports, most notably the :pretty option.

Summary

Types

Functions

Link to this function

from_rdf(dataset, options \\ %Options{})

View Source
@spec from_rdf(RDF.Data.t(), JSON.LD.Options.t() | Enum.t()) ::
  {:ok, [map()]} | {:error, any()}
Link to this function

from_rdf!(rdf_data, options \\ %Options{})

View Source
@spec from_rdf!(RDF.Data.t(), JSON.LD.Options.t() | Enum.t()) :: [map()]