JSV.Codec (jsv v0.7.2)
View SourceJSON encoder/decoder based on available implementation.
First looks for Jason, then Poision, then JSON (available since Elixir 1.18).
Summary
Functions
Returns the module used for JSON encoding and decoding.
Equivalent to JSON.decode/1
.
Equivalent to JSON.decode!/1
.
Equivalent to JSON.encode!/1
.
Equivalent to JSON.encode_to_iodata!/1
.
Equivalent to JSON.encode!/1
with human readable indentation.
Equivalent to JSON.encode!/1
with map keys ordered according to the sorter
function.
Like format_ordered!/2
but returns iodata instead of strings.
Equivalent to JSON.encode_to_iodata!/1
with human readable indentation.
Types
Functions
@spec codec() :: module()
Returns the module used for JSON encoding and decoding.
Equivalent to JSON.decode/1
.
Equivalent to JSON.decode!/1
.
Equivalent to JSON.encode!/1
.
Equivalent to JSON.encode_to_iodata!/1
.
Equivalent to JSON.encode!/1
with human readable indentation.
Requires Jason
or Poison
for Elixir versions before 1.18 and OTP before
27.0.
@spec format_ordered!(term(), key_sorter()) :: binary()
Equivalent to JSON.encode!/1
with map keys ordered according to the sorter
function.
The sorter function will be called with two keys from the same map and should
return true
if the first argument precedes or is in the same place as the
second one.
Requires Jason
for Elixir versions before 1.18 and OTP before 27.1.
Data must be normalized before ordered encoding. Passing structs will result
in an error. Use JSV.Normalizer.normalize/1
to normalize data in a
compatible form.
@spec format_ordered_to_iodata!(term(), key_sorter()) :: iodata()
Like format_ordered!/2
but returns iodata instead of strings.
Equivalent to JSON.encode_to_iodata!/1
with human readable indentation.