Alaja.Components.Json (Alaja v2.0.0)

Copy Markdown View Source

Static JSON pretty-printer with syntax highlighting for terminal output.

Renders JSON with ANSI colors differentiated by value type.

Usage

iex> Alaja.Components.Json.print(%{name: "Alaja", version: "1.0.0"})

Cell engine

As of v0.3.0, render/2 returns an Alaja.Buffer.t/0. Each line becomes one row; multi-line JSON (objects, arrays) become multi-row buffers. Each character is placed with the colour matching its JSON token type.

Theme integration (v2.0.0+)

When no :key_color / :string_color / etc. are supplied, the defaults are theme:quaternary, theme:success, theme:info, theme:ternary, theme:sad, theme:no_color — they resolve through Pote.Orchestrator.parse_color/1 so the active theme picks them up. Pass an RGB tuple, hex string, or atom to override.

Summary

Functions

Prints JSON to stdout with syntax highlighting.

Renders JSON to an Alaja.Buffer.t/0.

Functions

print(data, opts \\ [])

@spec print(
  term(),
  keyword()
) :: :ok

Prints JSON to stdout with syntax highlighting.

render(data, opts \\ [])

@spec render(
  term(),
  keyword()
) :: Alaja.Buffer.t()

Renders JSON to an Alaja.Buffer.t/0.