jakartaee / jsonb-api

Jakarta JSON Binding
https://eclipse-ee4j.github.io/jsonb-api/
Other
78 stars 39 forks source link

Add JsonbEnumValue annotation for enumerated types #255

Open KeyBridge opened 4 years ago

KeyBridge commented 4 years ago

Json-b presently does not appear to recognize or honor @JsonbProperty annotation when applied to enumerated types. We suggest adding an annotation type that implements the same logic as @XmlEnumValue

Without this function a custom type adapter is required for all enumerated types with non-Java characters (e.g. '-') in their names. For example, the first entry in the following enum requires a dash instead of underscore. @JsonbProperty is presently not picked up or recognized.


public enum foo {
  @JsonbEnumValue("A256CBC-HS512")
  A256CBC_HS512,
  A128GCM;
}

Thanks!

Referencing [https://docs.oracle.com/javase/8/docs/api/javax/xml/bind/annotation/XmlEnumValue.html](XmlEnumValue)
rmannibucau commented 4 years ago

Hi @KeyBridge ,

What about reusing @JsonbProperty which looks the more intuitive solution to me?

edit: made johnzon supporting it https://issues.apache.org/jira/browse/JOHNZON-321

KeyBridge commented 4 years ago

Absolutely.

If possible, extending @JsonbProperty to recognize enum types would be easier for the user.