gaato/sdk-runtime/json does not have a README file

    ObjBuilder

    pub struct ObjBuilder {
    // private fields
    }

    Mutable object builder retaining each key's original insertion position.

    test {
    let builder = @json.ObjBuilder::new()
    .field("name", "sample")
    .opt("count", (None : Int?))
    .presence("note", (@json.Null : @json.Presence[String]))
    assert_eq(builder.build(), { "name": "sample", "note": null })
    }

    ObjBuilder::build

    fn ObjBuilder::build(self : ObjBuilder) -> Json

    Returns a snapshot of the current fields, preserving insertion order.

    ObjBuilder::field

    fn[T : ToJson] ObjBuilder::field(self : ObjBuilder, key : String, value : T) -> ObjBuilder

    Writes a field, replacing any previous value at its original position.

    ObjBuilder::new

    fn ObjBuilder::new() -> ObjBuilder

    Creates an empty builder.

    ObjBuilder::opt

    fn[T : ToJson] ObjBuilder::opt(self : ObjBuilder, key : String, value : T?) -> ObjBuilder

    Writes Some values and leaves the builder unchanged for None.

    ObjBuilder::presence

    fn[T : ToJson] ObjBuilder::presence(self : ObjBuilder, key : String, value : Presence[T]) -> ObjBuilder

    Omits Absent, writes null for Null, and encodes Value.

    Presence

    pub(all) enum Presence[T] {
    Absent
    Null
    Value(T)
    } derive(Eq,
    Debug
    )

    Distinguishes an omitted property from null and a present value.

    test {
    let value = @json.Presence::from_option(Some(3))
    assert_eq(value.map(n => n + 1).to_option(), Some(4))
    assert_false(value.is_absent())
    }

    Presence::equal

    fn[T : Eq] Presence::equal(Presence[T], Presence[T]) -> Bool

    Compares presence and, for Value, the contained value.

    Presence::from_option

    fn[T] Presence::from_option(value : T?) -> Presence[T]

    Represents None as omission.

    Presence::is_absent

    fn[T] Presence::is_absent(self : Presence[T]) -> Bool

    Reports omission, as distinct from an explicit null.

    Presence::map

    fn[T, U] Presence::map(self : Presence[T], f : (T) -> U) -> Presence[U]

    Transforms only a present value, preserving omission and null.

    Presence::not_equal

    fn[T : Eq] Presence::not_equal(x : Presence[T], y : Presence[T]) -> Bool

    Compares presence and, for Value, the contained value.

    Presence::to_option

    fn[T] Presence::to_option(self : Presence[T]) -> T?

    Collapses both omission and null to None.

    Presence::to_repr

    Formats the presence state and its value for debugging.

    expect_object

    Extracts an object's fields or raises at the supplied path.

    field

    Decodes a required field, attaching the key to missing or invalid value errors.

    open_int

    fn[T] open_int(json : Json, path :
    JsonPath
    , known : (Int) -> T?, unknown : (Int) -> T) -> T raise
    JsonDecodeError

    Decodes an open integer enum, rejecting fractions and values outside Int.

    open_string

    fn[T] open_string(json : Json, path :
    JsonPath
    , known : (String) -> T?, unknown : (String) -> T) -> T raise
    JsonDecodeError

    Decodes a string enum, preserving unrecognized values through unknown.

    opt_field

    Treats missing fields and null as None; other values must decode as T.

    presence_field

    Preserves missing, null, and decoded values as three distinct cases.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io