Annotation Interface JsonbCreator


Annotates a constructor or static factory method to use for deserialization.

By default, deserialization of a class invokes its no-argument constructor, and deserialization of a record invokes its canonical constructor. A record may also declare a compact constructor whose body is merged into the canonical constructor at compile time; the two are indistinguishable at runtime and both serve as the canonical deserialization path without requiring @JsonbCreator.

This annotation identifies a custom constructor or static factory method to invoke when creating an instance of the associated class or record during deserialization.

Only one constructor or static factory method per class or record may be annotated with @JsonbCreator.

Parameters of the annotated constructor or static factory method may themselves be annotated, for example with JsonbProperty.

Usage

The @JsonbCreator annotation can be used with the following program elements:

  • method
  • constructor

Since 3.1: @JsonbCreator may also be placed on a non-canonical constructor or static factory method of a Java record to designate an alternative deserialization path.

Since:
JSON Binding 1.0