jsonb-api icon indicating copy to clipboard operation
jsonb-api copied to clipboard

Add JsonbEnumValue annotation for enumerated types

Open KeyBridge opened this issue 5 years ago • 2 comments

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)

KeyBridge avatar Aug 18 '20 22:08 KeyBridge

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

rmannibucau avatar Aug 19 '20 07:08 rmannibucau

Absolutely.

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

KeyBridge avatar Aug 21 '20 16:08 KeyBridge