Gleam.br Wiki

📃 JSON/JSON-RPC/JSON-Schema | Governança

Especificação técnica e manual do componente gbr_json.

Package Version Hex Docs

📃 JSON/JSON-RPC/JSON-Schema

JSON Schema library to load into AST and gen gleam code definition types. > and JSON helper functions

Roadmap

  • [ ] Update json schema to https://json-schema.org/draft/2020-12/schema - [ ] Parser error

Running

gleam add gbr_json
import simplifile

import gbr/json/schema

pub fn main() -> Nil {
  let path = "./priv/2025-06-18-schema.json"
  let field = "definitions"

  let content = path
  |> simplifile.read()
  |> result.map_error(fn(err) {
    "[ERR] Reading " <> path <> ": " <> string.inspect(err)
  })

  case schema.load(content, field) {
    Ok(output) -> io.println("> Definitions:\n" <> output)
    Error(err) -> io.println_error(err)
  }
}

Development

gleam run   # Run the project
gleam test  # Run the tests