kosei28/maru/json does not have a README file

Parser

type Parser[T] = (Value) -> T raise
Invalid

A function that parses a Value into T.

Object

type Object

An object together with the path used in error messages.

Object::field

fn Object::field(self : Object, name : String) -> Value raise
Invalid

Get a required field. Missing keys raise; JSON null is still a Value.

Object::optional_field

fn Object::optional_field(self : Object, name : String) -> Value?

Get an optional field.

Returns None only when the key is absent. JSON null is Some(Value).

Value

type Value

A JSON value together with the path used in error messages.

Value::array

Convert this value to an array of Values.

Value::bool

Convert this value to Bool.

Value::double

Convert this value to Double.

JSON numbers that overflow to infinity are rejected.

Value::int

Convert this value to Int.

JSON numbers must be finite integers in the 32-bit range.

Value::int64

Convert this value to Int64.

JSON numbers must be finite integers in the 64-bit range.

Value::null

fn Value::null(self : Value) -> Unit raise
Invalid

Require this value to be JSON null.

Value::object

Convert this value to an object.

Value::raw

fn Value::raw(self : Value) -> Json

Return the underlying JSON. Use this as an escape hatch for types that maru does not convert directly.

Value::string

Convert this value to String.

first_of

fn[T] first_of(value : Value, parsers : Array[(Value) -> T raise
Invalid
]) -> T raise
Invalid

Try each parser in order and return the first success.

Raises when every parser fails.

from_json

fn from_json(json : Json) -> Value

Wrap JSON as a Value so it can be validated while a typed value is built.

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io