TOML to serde.zig
TOML configs turn into Zig structs annotated for serde.zig. Use deny_unknown_fields from Options to reject typos in config keys.
Strict configConservative u64; enums off; observed scalar values become Zig defaults — best for TOML/YAML configs.
title = "myapp" port = 3000 debug = false [database] host = "localhost" name = "main"
Config.zig const serde = @import("serde");
pub const Config = struct {
title: []const u8 = "myapp",
port: u64 = 3000,
debug: bool = false,
database: Database,
};
pub const Database = struct {
host: []const u8 = "localhost",
name: []const u8 = "main",
};
Field decisions
Why each field got its type. Click a row to see it in the input; edit to override.
struct Config $ 4 fields
struct Database $.database 2 fields
What you get
- Nested structs for every table, slices for arrays of tables.
- Defaults from observed values with the Strict preset.
.deny_unknown_fields = trueon every struct when you turn it on.
Questions
- Can serde.zig reject unknown config keys?
- Yes. Enable deny_unknown_fields in Options and parsing fails with
error.UnknownFieldon any key the struct doesn't declare.