jsonb-api
jsonb-api copied to clipboard
Support AnnotatedType
Since Java 8 introduced TYPE_USE annotations, and this API is a Java standard as well, one would expect the two to work together.
I suggest JSON-B is enhanced (the implementation at least, if not the spec) to support AnnotatedType
.
Namely, the following methods should exist:
-
Jsonb#fromJson(String, AnnotatedType)
-
JsonbDeserializer#deserialize(JsonParser, DeserializationContext, AnnotatedType)
The rationale is that the deserializer gains the ability to make decisions based on the type annotations.
E.g.
For a type such as List<@Base64 Key>
it would be possible to create a (de)serializer that performs custom logic (e.g. Base64-encode/decode the value on the way in/out) for types annotated with @Base64
regardless of their class.
- Issue Imported From: https://github.com/javaee/jsonb-spec/issues/66
- Original Issue Raised By:@kaqqao
- Original Issue Assigned To: Unassigned
@m0mus Commented Added to the next spec version proposed features.
This would also be useful for conditional formatting such as a view on the JSON (a-la Jackson JSON Views). Not sure if this also means there should be a #deserialze(JsonParser, DeserialisationContext, Annotation... annotations)
method too or decomposing to AnnotatedElement
as AnnotatedType
doesn't cover a parameter or variable use case.
Hi, I'm not sure the goal since Type covers all potential cases of JSON-B as of today and there is no use case we can't cover with such API so can be neat to keep the API sane to avoid indirections and needed overrides in integrations to support way more base API (otherwise customizations will become a mess and no more usable properly since methods will conflicts or builders will be ultra verbose for ex).