-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Support java record deserialization on Android #4166
Comments
This sounds like a cool module idea; use of Fields as a work-around isn't good approach. As to how to contribute... my initial thinking is that if build could work on JavaSE platform, module could be included as part of But much depends on details. |
Just posted a PR.
I'm curious: what did you mean by this? |
@eranl I mean that forcing direct access to non-public fields can become problematic, compared to using accessors. |
I see. The code uses field metadata, but doesn't access fields for reading/writing data. |
Implemented via FasterXML/jackson-modules-base#230 -- closing |
Is your feature request related to a problem? Please describe.
On a range of Android SDK versions <34, java records are supported through desugaring. Jackson's built-in support for records doesn't work on these platforms, since the classes have a non-standard super class, and record component-related reflection methods are missing.
Serialization of records works fine with
setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
, but deserialization fails there.Describe the solution you'd like
I created a Jackson module that adds automatic support for Android-desugared record deserialization, by matching constructor signatures with field types. It has one minor limitation: it doesn't allow a deserialized record to have a custom constructor with a signature that's any permutation of the canonical one's.
Can I contribute this module? How?
Usage example
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: