-
Notifications
You must be signed in to change notification settings - Fork 83
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 AnnotatedType/TYPE_USE annotations #5
Comments
Jackson unfortunately can't handle this case, because it targets Java <8. Still, the author is open to this in the upcoming Jackson 3, so I'll attempt to contribute this extension. |
@kaqqao I use jackson, and to me it still seems possible to create a custom deserializer that itself is Java 8 aware. Pardon the Kotlin, but this is from some of my company's code: var json: String = ""
@JsonRawValue
get() = field
@JsonDeserialize(using = MyCustomDeserializer::class)
set(value) {field = value} ... this could easily be annotated with a Java 8 type annotation such as: @Base64
var json: String = ""
@JsonRawValue
get() = field
@JsonDeserialize(using = Jsr308Deserializer::class)
set(value) {field = value} ... where Have you tried it? |
It is possible to recover annotations on fields/methods, yes, but TYPE_USE annotations are not preserved in Jackson's I've already talked to the Jackson's author, he confirmed my understanding... |
Btw, feel free to close the issue if you don't really want it open for a hibernating project or don't want the feature in general. And thanks for the responses! |
@kaqqao Thanks for the clarification. I get it. I'm familar with some of the jackson internals. I'll leave this open, as it sounds useful. |
Not sure how and if this project is active, but here's a suggestion.
Since this library is Java 8+ only, it would make a lot of sense that it supports
AnnotatedType
when deserializing, especially if the support for user-defined (de)serializers is added.This would allow fine grained logic in the custom (de)serializers.
E.g. A custom (de)serializer could be written to process types such as
List<@Base64 Book>
by Base64-de/encoding the JSON value before the usual (de)serialization.I've been looking for a Java JSON library with such capabilities for use in my project, and exactly 0 exist. I maintain a library for advanced reflection that works with
AnnotatedType
but don't really have the capacity to develop a JsSON library as well, so I'm opening this suggestion on projects that are Java 8+ only or in early development (as this one seems to be).The text was updated successfully, but these errors were encountered: