# `Grephql.JSON`
[🔗](https://github.com/fahchen/grephql/blob/v0.10.1/lib/grephql/json.ex#L1)

Behaviour for JSON encoding/decoding.

By default, uses Elixir's built-in `JSON` module (available since Elixir 1.18)
when present, falling back to `Jason`. If neither is available, raises at runtime.

To override the auto-detected default:

    config :grephql, :json_library, Jason

A custom implementation must export `encode!/1` and `decode/1`
(see `@callback` definitions below).

# `decode`

```elixir
@callback decode(String.t()) :: {:ok, term()} | {:error, term()}
```

# `encode!`

```elixir
@callback encode!(term()) :: String.t()
```

# `decode`

```elixir
@spec decode(String.t()) :: {:ok, term()} | {:error, term()}
```

Decodes a JSON string. Returns `{:ok, term}` or `{:error, reason}`.

# `encode!`

```elixir
@spec encode!(term()) :: String.t()
```

Encodes a term to a JSON string. Raises on failure.

# `library`

```elixir
@spec library() :: module()
```

Returns the configured JSON library module.

---

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