Alaja.Components.Json (Alaja v1.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"})
# {
#   "name": "Alaja",
#   "version": "1.0.0"
# }

Summary

Functions

Prints JSON to stdout with syntax highlighting.

Renders JSON to iodata without printing.

Functions

print(data, opts \\ [])

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

Prints JSON to stdout with syntax highlighting.

Options

  • :indent - Indentation in spaces (default: 2)
  • :key_color - RGB for object keys
  • :string_color - RGB for string values
  • :number_color - RGB for numbers
  • :boolean_color - RGB for booleans
  • :null_color - RGB for null values

render(data, opts \\ [])

@spec render(
  term(),
  keyword()
) :: iodata()

Renders JSON to iodata without printing.