But cereal doesn't look like it has a way to do this. make_nvp, from my knowledge, requires the sub-fields to be static, so the value field can't change it's serialization based on the kind.
Is there a way it can be done, and if not, could a feature like it be added?
This problem can't be solved by delegating it to a child structure, because the serialization of the value depends on family (e.g. if family is keyboard, it uses a different enum than if family is gamepad)
Also, InputButton and InputAcis are themselves unions (Of KeyboardButton, GamepadButton, and MouseButton for buttons, and GamepadAxis and MouseAxis for axes)
Hi! I have the following data structure in my code:
And I want to serialize it to a JSON structure like this:
But cereal doesn't look like it has a way to do this.
make_nvp
, from my knowledge, requires the sub-fields to be static, so thevalue
field can't change it's serialization based on thekind
.Is there a way it can be done, and if not, could a feature like it be added?
This problem can't be solved by delegating it to a child structure, because the serialization of the value depends on
family
(e.g. iffamily
is keyboard, it uses a different enum than iffamily
is gamepad)Also,
InputButton
andInputAcis
are themselves unions (OfKeyboardButton
,GamepadButton
, andMouseButton
for buttons, andGamepadAxis
andMouseAxis
for axes)