The goal is to serialize TypeA and TypeB into different formats. Specifically, TypeB should be serialized into a more compact format than TypeA.
Expected Behavior
TypeA should be serialized using the default serialization format.
TypeB should be serialized using a custom, compact format as indicated by the #[special_compact] attribute.
Actual Behavior
Currently, both TypeA and TypeB are serialized using the same format, and there doesn't seem to be an out-of-the-box solution for differentiating their serialization formats.
Request for Solution
Is there a way to achieve this within the current framework of serde? If not, could you provide guidance or a potential feature enhancement to support this functionality?
Problem Statement
I have the following struct definitions:
The goal is to serialize
TypeA
andTypeB
into different formats. Specifically,TypeB
should be serialized into a more compact format thanTypeA
.Expected Behavior
TypeA
should be serialized using the default serialization format.TypeB
should be serialized using a custom, compact format as indicated by the#[special_compact]
attribute.Actual Behavior
Currently, both
TypeA
andTypeB
are serialized using the same format, and there doesn't seem to be an out-of-the-box solution for differentiating their serialization formats.Request for Solution
Is there a way to achieve this within the current framework of
serde
? If not, could you provide guidance or a potential feature enhancement to support this functionality?Thank you!