Add example on automatic compaction during encoding
This commit is contained in:
parent
f3bc0a1d84
commit
ad61223c53
1 changed files with 7 additions and 1 deletions
|
@ -121,10 +121,16 @@ dataset = JSON.LD.read_file!("file.jsonld")
|
||||||
JSON.LD.write_file!(dataset, "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
|
||||||
|
|
||||||
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
|
```elixir
|
||||||
JSON.LD.write_file!(dataset, "file.jsonld", pretty: true)
|
JSON.LD.write_file!(dataset, "file.jsonld", pretty: true)
|
||||||
|
|
Loading…
Reference in a new issue