Bolty.ResponseEncoder.Json.Native (Bolty v0.3.0)

Copy Markdown View Source

JSON.Encoder implementations for Bolty.Types.*, using Elixir's built-in JSON (Elixir 1.18+).

These let a query result — or any value containing Bolty types — be handed straight to JSON.encode!/1:

{:ok, conn} = Bolty.start_link(uri: "bolt://localhost:7687", auth: [username: "neo4j", password: "..."])
{:ok, res} = Bolty.query(conn, "MATCH (t:TestNode) RETURN t")
JSON.encode!(res)

Each implementation first runs the value through the Bolty.ResponseEncoder.Json protocol (which normalises a Bolty type into a plain jsonable value), then hands the result to the matching built-in JSON.Encoder. Override the jsonable step by providing your own Bolty.ResponseEncoder.Json implementation.