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

Add JsonbAccessorType class annotation

Open KeyBridge opened this issue 5 years ago • 0 comments

It would be very convenient to have an analogue to the @XmlAccessortype annotation for Jsonb.

Jsonb presently reads fields plus methods. For complex classes having many helper methods this can require extensive @JsonbTransient annotation. Presently it is necessary to either write a custom visibility strategy or extensively decorate existing code specifically for JSON, where with XML it is not.

For example, in the following class, we would prefer to simply add a class-level annotation to ignore the isValid method (and all other methods...)

@JsonbAccessorType(JsonbAccessType.FIELD)
public class Foo extends Bar implements Serializable {

public boolean isValid(){}

This references

  • https://docs.oracle.com/javase/7/docs/api/javax/xml/bind/annotation/XmlAccessorType.html
  • https://docs.oracle.com/javase/7/docs/api/javax/xml/bind/annotation/XmlAccessType.html

KeyBridge avatar Aug 21 '20 16:08 KeyBridge