Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update jsonb.adoc - Annotate adapter on a class #340

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions spec/src/main/asciidoc/jsonb.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -733,13 +733,14 @@ On serialization of Original type JSONB calls `JsonbAdapter::adaptToJson` method

On deserialization JSONB deserializes Adapted from JSON and converts it to Original using `JsonbAdapter::adaptFromJson` method.

There are two ways how to register `JsonbAdapter`:
There are three ways how to register `JsonbAdapter`:

[arabic]
. Using `JsonbConfig::withAdapters` method;
. Annotating a class field with `JsonbTypeAdapter` annotation.
. Annotating a type with `JsonbTypeAdapter` annotation.

`JsonbAdapter` registered via `JsonbConfig::withAdapters` is visible to all serialize/deserialize operations performed with given `JsonbConfig`. `JsonbAdapter` registered with annotation is visible to serialize/deserialize operation used only for annotated field.
`JsonbAdapter` registered via `JsonbConfig::withAdapters` is visible to all serialize/deserialize operations performed with given `JsonbConfig`. `JsonbAdapter` registered with annotation on a *field* is visible to serialize/deserialize operation used only for annotated field. `JsonbAdapter` registered with annotation on a *class* is visible to all serialize/deserialize operations of the annotated class.

It is possible to annotate `JsonbCreator` parameter with `JsonbTypeAdapter` and provide adapter for a parameter this way. However, if `JsonbTypeAdapter` annotation is provided to any other parameter (such as setter method parameter) it will be ignored.

Expand Down