# `ExWapp.JSON`
[🔗](https://github.com/elchemista/ex_wapp/blob/v0.1.5/lib/ex_wapp/json.ex#L1)

Configurable JSON boundary used by ExWapp.

ExWapp deliberately does not depend on a JSON implementation. The host
application must provide a module exposing `encode/1` and `decode/1` with
the conventional `{:ok, value} | {:error, reason}` return shape:

    config :ex_wapp, :json_library, Jason

Jason, Poison, Elixir's `JSON` module, or a small adapter around another
implementation can be used. Modules exposing only the bang variants are
supported too.

# `error_reason`

```elixir
@type error_reason() ::
  :json_library_not_configured
  | {:invalid_json_library, term()}
  | {:invalid_json_library_response, :encode | :decode, term()}
  | term()
```

# `decode`

```elixir
@spec decode(iodata()) :: {:ok, term()} | {:error, error_reason()}
```

Decodes JSON with the configured JSON implementation.

# `decode!`

```elixir
@spec decode!(iodata()) :: term() | no_return()
```

Decodes JSON or raises when JSON is unavailable or decoding fails.

# `encode`

```elixir
@spec encode(term()) :: {:ok, binary()} | {:error, error_reason()}
```

Encodes a value with the configured JSON implementation.

# `encode!`

```elixir
@spec encode!(term()) :: binary() | no_return()
```

Encodes a value or raises when JSON is unavailable or encoding fails.

# `library`

```elixir
@spec library() :: {:ok, module()} | {:error, error_reason()}
```

Returns the JSON module configured by the host application.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
