Help for zon

Currently I’m using yaml in Python (with ruamel.yaml) but I want to try using zig. The two choices are zon and ziggy.

Here is an example file: workout file · GitHub

The problem I’m having with zon is how to describe a list of steps.

Thanks.

1 Like
.{
    .workout = .{
        .name = "aerobic-threshold",
        .defaults = .{
            .mode = "target-power",
        },

        .steps = .{
            .{
                .name = "warm-up",
                .power = "[100, 160]",
                .cadence = "[0, 95]",
                .@"duration-minutes" = 10,
                .note =
                \\Increase cadence gradually until 90-95rmp.
                \\Increase power gradually until 160W.
                ,
            },

            .{
                .name = "fast-pedaling",
                .active = .{
                    .power = 160,
                    .cadence = "[100, 120]",
                    .@"duration-minutes" = 1,
                },
                .recovery = .{
                    .power = 150,
                    .cadence = "[90, 95]",
                    .@"duration-minutes" = 1,
                },
                .reps = 3,
            },

            .{
                .name = "aerobic",
                .mode = "simulation",
                .slope = 0,
                .gear = "[52, 22]", // 2-4
                .power = "[160, 180]",
                .@"heart-rate" = "[113, 117]",
                .cadence = "[90, 95]",
            },

            .{
                .name = "cool-down",
                .power = "[90, 130]",
                .cadence = "[90, 100]",
                .@"duration-minutes" = 15,
            },
        },
    },
}

You can describe a list of steps in Zon as a tuple: .{.{.name = "warm-up", ...}, .{.name = "fast-pedaling", ...}, ...}

Realistically, zon is fairly limited and you may end up writing a lot of boilerplate, you’ll probably want ziggy or a parser for your favorite serialization format.

Thanks. As I suspected it was a trivial problem, I forgot to add a second curly brace.

Thanks also for converting the yaml file to zon.
I decided to use _ instead of -.

A feature I would like is to add indentation to the multiline string literals; it should increase the readability but i’m not sure if may cause problems.

1 Like