# `Monty.Frameworks.Actions.ActionJSONDecoder`
[🔗](https://github.com/d-led/ex.tbp.monty/blob/v0.1.0/packages/ex_tbp_monty_core/lib/monty/frameworks/actions/action_json_decoder.ex#L1)

The action a map names.

Mirrors `tbp/monty/frameworks/actions/actions.py::ActionJSONDecoder`, which
reads a map whose `"action"` key names the action and whose other keys are
that action's parameters.

Monty raises `ValueError` for a map with no name, an unknown name, or a
parameter missing. This answers `{:error, reason}` instead: such a map arrives
from outside the beam, and a run should be able to say what was wrong with it
rather than end.

Quaternions are answered as `{w, x, y, z}` tuples, which is how the structs
hold them; JSON has no tuples, so Monty converts on the way in as well.

# `decode`

```elixir
@spec decode(map()) :: {:ok, Monty.Frameworks.Actions.Action.t()} | {:error, term()}
```

The action `object` describes, or what is wrong with the object.

`{:error, :missing_action}` for a map with no `"action"` key,
`{:error, {:unknown_action, name}}` for one naming an action this port does
not have, and `{:error, {:missing_parameter, name}}` for one that leaves a
parameter out.

---

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