JSON codec indirection.
JSON needs no dependency of its own. The codec is resolved, once, in this order:
- the module configured as
config :typedb, :json_codec, MyCodec TypeDB.JSON.Native, backed by the built-inJSONmodule — this is what every supported Elixir version (1.18+) resolves toTypeDB.JSON.Jason, when the host application depends on:jason- otherwise an error is raised, asking you to pick one
A codec is any module implementing this behaviour.
Summary
Callbacks
Decodes a JSON binary. Returns {:error, reason} on malformed input.
Encodes a term to JSON iodata. Raises on unencodable input.
Functions
Returns the resolved codec module.
Decodes a JSON binary.
Encodes term to a JSON binary.
Encodes term to JSON iodata.
Forgets the memoised codec. Intended for tests.
Callbacks
Functions
@spec codec() :: module()
Returns the resolved codec module.
The result is memoised in :persistent_term. Change :json_codec before the
first call, or call reset/0 afterwards.
Decodes a JSON binary.
Encodes term to a JSON binary.
Encodes term to JSON iodata.
@spec reset() :: :ok
Forgets the memoised codec. Intended for tests.