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

feat(Entity): OOP-ify the array deserialization mess #566

Merged
merged 3 commits into from
Sep 30, 2023

Conversation

GeopJr
Copy link
Owner

@GeopJr GeopJr commented Sep 27, 2023

ArrayList deserialization from JSON has been very messy. There's a huge switch statement that goes through each possible property name to find the type. Not only is that unmaintainable but also leads to property conflicts:

For example an entity that has an uploads property of string and an entity that also has an uploads property but of API.Attachment cannot co-exist. We've been lucky so far that there haven't been any conflicts.

This PR creates a virtual function that returns a Type for a property name, allowing descendants to override it for their needs.

this will make adding more properties easier in the future
API.Poll has always been the odd one out as it doesn't inherit from Entity and Widgetizable but implemented its deserialization manually
@GeopJr GeopJr merged commit b3f2ab3 into main Sep 30, 2023
4 checks passed
@GeopJr GeopJr deleted the feat/entity/oop-ify-the-array-deserialization-mess branch September 30, 2023 00:31
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

Successfully merging this pull request may close these issues.

1 participant