struct Proxy { import std.conv; static void serialize(ref Packer p, ref int val) { p.pack(to!string(val)); } static void deserialize(ref Unpacker u, ref int val) { string tmp; u.unpack(tmp); val = to!int(tmp); } } struct S { // The Packer/Unpacker proxy handler is applied this field. @serializedAs!Proxy int num; string str; }
Attribute for specifying serialize/deserialize proxy for pack/unpack field. This is an alternative approach of registerPackHandler/registerUnpackHandler.