jakartaee / jakartaee/jsonb-api

Registration of JsonbAdapter on target class

Open
#372 6 comments 2 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
95
Forks
41
Avg merge
1d 6h
Merged PRs (30d)
35

Description

The proposal is to update Jakarta JSON Binding 3.0 section `4.7.1. Adapters` so that an adapter can be registered on the adapted class itself. For example:

```
@JsonbTypeAdapter(EmailAddressAdapter.class)
public class EmailAddress {

private String value;

public EmailAddress(String value) {
this.value = value;
}

public String getValue() {
return value;
}
}

```

And

```
public class EmailAddressAdapter implements JsonbAdapter {

@Override
public String adaptToJson(EmailAddress obj) {
return obj.getValue();
}

@Override
public EmailAddress adaptFromJson(String obj) {
return new EmailAddress(obj);
}
}

```

For the purposes specification backwards compatibility and the ability to override an adapter, the existing two forms would take precedence. This is consistent with the specification's requirement use of JsonbTypeAdapter on parameters be ignored if it the adapter is defined on a field or in the config.

Contributor guide

Open the contributing guide

Research direction

Start by reading Jakarta JSON Binding 3.0 section 4.7.1, “Adapters,” and review the existing precedence rules described in the issue. The work is complete when the specification clearly defines registration on the adapted class, including backwards compatibility and adapter override behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.