# `MqttX.Payload.JSON`
[🔗](https://github.com/cignosystems/mqttx/blob/v0.11.2/lib/mqttx/payload/json.ex#L1)

JSON payload codec using the built-in Erlang/BEAM JSON encoder.

Uses the native JSON module available in OTP 27+ / Elixir 1.18+.

## Usage

    {:ok, json} = MqttX.Payload.JSON.encode(%{temp: 25.5})
    {:ok, data} = MqttX.Payload.JSON.decode(json)

On runtimes without the native `JSON` module, `encode/1` and `decode/1`
return `{:error, :json_not_available}` instead of raising
`UndefinedFunctionError` (mirroring `MqttX.Payload.Protobuf`'s graceful
degradation).

---

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