This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 8/19/2026.
JSON
~import std/jsonstd/json - JSON encoding and decoding
json.kz · 8 tors
std/json - JSON encoding and decoding
Minimal JSON library for building and parsing JSON.
Uses Zig's std.json under the hood.
Design: Start simple, extend as needed.
- Object builder pattern for encoding
- Key-based extraction for decoding
Phantom lifecycles
Derived from the phantom labels in the declarations below — state! issues an
obligation the compiler will chase, !state discharges it, a bare state holds it without moving it. Nothing here is hand-drawn.
JsonObject 1 state building!// Object Builder - Create JSON objects
~pub tor object.new { allocator: ?std.mem.Allocator } -> *JsonObject<building!>~pub tor object.set {
obj: *JsonObject<building>,
key: string,
value: JsonValue
} -> *JsonObject<building>~pub tor object.finish { obj: *JsonObject<!building> } -> string// Array Builder - Create JSON arrays
~pub tor array.new { allocator: ?std.mem.Allocator } -> *JsonObject<building!>~pub tor array.push {
arr: *JsonObject<building>,
value: JsonValue
} -> *JsonObject<building>~pub tor array.finish { arr: *JsonObject<!building> } -> stringget.string
koru_std/json.kz:175// Decoding - Extract values from JSON strings
~pub tor get.string { json: string, key: string }
| ok string
| not-foundget.int
koru_std/json.kz:212~pub tor get.int { json: string, key: string }
| ok i64
| not-found