News for hackers. Stuff that matters.
Re:Understanding Serde by dangets on Monday November 18, 2019 @10:24AM (#21564956)
This is where I would either a) create 2 separate DTO representations with adapters to the internal domain object or b) have a trait which the 2 specialized structs implement. This conversion point is also a good place to do your validation that the object is in a consistent state. This isn't quite zero-cost - but it does isolate your external serialization code from your internal logic and it is easier to add even more formats in the future.

And at least in Java-land is much cleaner than stacking lots and lots of annotations on the same struct.

There are no comments on this comment yet.