From ad61223c532c6eacb4582ef02c1f9e0cf576b0fa Mon Sep 17 00:00:00 2001 From: Marcel Otto Date: Mon, 25 Apr 2022 21:36:38 +0200 Subject: [PATCH] Add example on automatic compaction during encoding --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4308404..7bc5e14 100644 --- a/README.md +++ b/README.md @@ -121,10 +121,16 @@ dataset = JSON.LD.read_file!("file.jsonld") JSON.LD.write_file!(dataset, "file.jsonld") ``` +When a context is provided via the `:context` option (as a map, a `RDF.PropertyMap` or a string with a URL to a remote context), the document gets automatically compacted on serialization. + +```elixir +JSON.LD.write_file!(dataset, "file.jsonld", context: %{ex: "https://example.com/"}) +JSON.LD.write_file!(dataset, "file.jsonld", context: "https://schema.org/") +``` ## Pretty printing -Pretty printing is possible on all writer functions with all of the formatter options of [Jason](https://hexdocs.pm/jason/Jason.Formatter.html#pretty_print/2), the underlying JSON encoder, to which the given options are passed through. +Pretty printing is possible on all writer functions with all the formatter options of [Jason](https://hexdocs.pm/jason/Jason.Formatter.html#pretty_print/2), the underlying JSON encoder, to which the given options are passed through. ```elixir JSON.LD.write_file!(dataset, "file.jsonld", pretty: true)