Hello everybody! So I have this interesting use c...
# serialization
h
Hello everybody! So I have this interesting use case that I cannot seem to be able to handle. I have a module with two interfaces,
Base
(which is sealed) and
Data
that extends it, and subclasses of
Data
that cannot be changed, and I have other modules where I can do anything. The comments in the code below should hopefully guide you.
Data
interface should be serialized taking into account only its text property (I use
ConcreteData
for deserializing). The issue is that while I can serialize arbitrary subclasses (represented by
RandomData
) in the context of
Data
, I cannot seem to do it in the context of
Base
. Any help would be greatly appreciated!
r
Pretty sure you're running into the same issue I posted literally the message above yours.
h
Actually your error seems to be regarding Boolean, which is the generic type in your case. I am pretty sure your code works without generics, whereas mine doesn't (no generics involved at all). Although, the solution to this might be shared, like somehow providing a serializer for the common superclass (in your case Any, in my case Data). But you would have no method to serialize Any at runtime, so maybe in your case it can actually be fixed with a registered contextual serializer.
r
Fair enough. I see you've already tried that solution with
customSerializersModule
though.
Contextual serializer didn't work for my use case. Wrapping my
T
value into a sealed
ValueHolder<T>
type did work though.