# `AshWorkflow.Charts.Json`
[🔗](https://github.com/team-alembic/ash_workflow/blob/v0.12.0/lib/ash_workflow/charts/json.ex#L1)

An `AshWorkflow.Charts.Graph` as plain data, for a client that draws the
workflow itself: D3 with a layout library such as dagre or ELK.js,
Cytoscape, React Flow, or a LiveView hook.

`to_map/1` returns maps with string keys, and every value is a string, a
boolean, `nil` or a list. Any JSON encoder can encode it, and a JavaScript
client reads the same names:

    %{
      "resource" => "MyApp.Candidate",
      "nodes" => [
        %{"id" => "review", "kind" => "manual", "initial" => false,
          "notes" => [%{"kind" => "policy", "name" => nil, "action" => nil,
                        "label" => "actor.role == :reviewer", "retry" => nil}]}
      ],
      "edges" => [
        %{"from" => "review", "to" => "escalated", "kind" => "timeout",
          "name" => "escalation", "label" => "after 7 days", "condition" => nil,
          "fallback" => false}
      ]
    }

`render/2` encodes that map with Jason.

# `render`

Encodes the map from `to_map/1` as JSON with Jason.

## Options

* `:pretty` — indent the JSON. Defaults to `false`.

# `to_map`

```elixir
@spec to_map(AshWorkflow.Charts.Graph.t()) :: map()
```

The graph as maps with string keys, ready for any JSON encoder.

---

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