Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom serialising of objects with inheritance #275

Closed
williamclocksin opened this issue Mar 12, 2024 · 2 comments
Closed

Custom serialising of objects with inheritance #275

williamclocksin opened this issue Mar 12, 2024 · 2 comments

Comments

@williamclocksin
Copy link

In my application, the object graph to be serialised contains objects that are subclassed about 5 or so deep. I have created custom readers and writers for one or more of the intermediate subclasses. However, when the objects are serialised, the entire inheritance structure of the object is not serialised. Only the subclasses with the custom readers/writers are serialised. What am I missing? In my custom reader/writer, do I need to do something analogous to super()? All the examples and tests do not use objects with inheritance, so I can't see how to do it. Thanks.

@williamclocksin
Copy link
Author

williamclocksin commented Mar 12, 2024

And, only the "lowest" subclass (that is, the final child of the inheritance farthest away from Object) that has a custom serialiser, is serialised. It is as though .toJson() and .toObjects() starts at the custom serialiser of the "lowest" subclass that has a custom serialiser, does that read/write, and then doesn't serialise the rest of the object.
So therefore, does the customer serialiser for the lowest subclass need to be responsible for serialising the entire object?

@jdereg
Copy link
Owner

jdereg commented Mar 13, 2024

The custom reader/writer for a class, is as you asked at the end, it is expected to handle the whole class, not a "slice."

@jdereg jdereg closed this as completed Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants