Skip to content

AppUtils: handle generic collection types for toJsonLiteral#2898

Open
Luna712 wants to merge 3 commits into
recloudstream:masterfrom
Luna712:patch-2
Open

AppUtils: handle generic collection types for toJsonLiteral#2898
Luna712 wants to merge 3 commits into
recloudstream:masterfrom
Luna712:patch-2

Conversation

@Luna712

@Luna712 Luna712 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

This is primarily for set key which calls toJsonLiteral, to avoid having to manually change every set key to determine proper serializers manually. This might have some edge cases where it doesn't fully work but under most circumstances it should.

}
}
// Handle generic collection/map types where type params are erased at runtime
// and no serializer can be found via reflection alone

@fire-light42 fire-light42 Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write test cases for this type of behavior, it looks very easy to break things here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% sure what to write for tests here. I have another method for this to recursively convert things to a JsonElement, more reliable maybe but a least a tiny bit less performant. The issue is that for things like setKey, the type ends up getting erased, which means we have a few other options also, make setKey always use reified for serialized classes, or pass the type directly. I am not 100% sure on the best path here.

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.

2 participants