# `JSON.LD.Encoder`
[🔗](https://github.com/rdf-elixir/jsonld-ex/blob/v1.0.1/lib/json/ld/encoder.ex#L1)

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

As for all encoders of `RDF.Serialization.Format`s, 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.

# `input`

```elixir
@type input() :: RDF.Dataset.t() | RDF.Description.t() | RDF.Graph.t()
```

# `from_rdf`

```elixir
@spec from_rdf(RDF.Data.Source.t(), JSON.LD.Options.t() | Enum.t()) ::
  {:ok, [map()]} | {:error, any()}
```

# `from_rdf!`

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
