How to serialize/deserialize a struct that has an ArrayList inside?

Something like this, without items and capacity in the json output? I think Zig should be able to serialize first party types by default?

const Foo = struct {
    Bar: []const u8,
    Baz: ArrayList(usize),
};

You haven’ mentioned what serialization format you’re talking about. There are a couple in the Zig std library, and there are packages for others.

Sorry I didn’t clearly… I’m talking about json from the standard library std.json.

You can add public jsonParse and jsonStringify functions to your type that override the default behaviour. std.json exposes internal functions that make this much easier.

std.json does have some wrappers around collections to do this, but it only has a managed array list wrapper.