YAML to serde.zig

YAML configs become Zig structs annotated for serde.zig. Anchors and merge keys resolve first, so the decoration reflects the document serde.zig will actually read.

Target

Strict configConservative u64; enums off; observed scalar values become Zig defaults — best for TOML/YAML configs.

# Service name shown in logs
name: myapp
replicas: 3
labels:
  app: api
  tier: backend
ports:
  - 8080
  - 8443
YAML 10 lines 113 B Drop files here to add samples
Config.zig
const serde = @import("serde");

pub const Config = struct {
    name: []const u8 = "myapp",
    replicas: u64 = 3,
    labels: Labels,
    ports: []const u64,
};

pub const Labels = struct {
    app: []const u8 = "api",
    tier: []const u8 = "backend",
};
loading zig fmt 2 structs · 6 fields 13 lines

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 Labels $.labels 2 fields

What you get

  • snake_case fields with .rename_all for camelCase or kebab-case keys.
  • Observed values as defaults with the Strict config preset.
  • A serde.yaml.fromSliceManaged helper and a test scaffold from the More menu.

Questions

Does serde.zig treat yes/no as booleans?
Not by default: it follows YAML 1.2, where yes and no are strings. zigshape infers them the same way.
Why are integers typed u8 or u16?
The API preset picks the smallest width that fits the samples. The Strict preset used here picks u64; you can also choose the strategy in Options.