IncidentIo. Json behaviour
(IncidentIo v0.3.1)
View Source
Behaviour for JSON encoding/decoding operations.
The JSON backend defaults to Jason but is swappable via application config,
which is useful in tests when you want to use a mock:
# config/test.exs
config :incident_io, :json_module, IncidentIo.Json.MockAny replacement module must implement the decode!/2 and encode!/2
callbacks defined by this behaviour.
Summary
Callbacks
Functions
Decodes a JSON binary into an Elixir term.
Delegates to the configured JSON module (default: Jason).
Example
IncidentIo.Json.decode!("{"key": "value"}")
#=> %{"key" => "value"}
Encodes an Elixir term into a JSON binary.
Delegates to the configured JSON module (default: Jason).
Example
IncidentIo.Json.encode!(%{key: "value"})
#=> "{"key":"value"}"