Documentation channel: current development main at compiler checkpoint 1d7e15e. The latest tagged release is v0.0.3; pages identify APIs that are not yet released.

JSON

json is a built-in Strut type backed by JSONIC. It is part of the core language, so JSON values and the json helpers do not require an include <json>; declaration. JSON object literals use braces, while maps use keyed square brackets so intent never depends on homogeneous-value inference.

JSON literals

function main() -> int {
    config := {"name": "Strut", "stable": true};
    print(config["name"]);
    return 0;
}

Navigation

port := config["port"];
name := config["server"]["name"];

Parse and stringify

data := json.parse(text);
compact := json.stringify(data);
pretty := json.pretty(data);

Encode native values

payload := json.encode(user);

Object helpers

public_view := user_json.pick(["id", "name"]);
without_secret := user_json.omit(["token"]);
merged := defaults.merge_deep(overrides);