jakartaee / jakartaee/jsonb-api

Harmonize JSONB / JAXB TypeAdapter behavior for Collections

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

Description

JSONB type adapter logic differs from JAXB in an important way for collections.

In JAXB when applied to a collection an `XmlJavaTypeAdapter` is applied to each entry in the collection.
_whereas_
In JSONB when applied to a collection an `JsonbTypeAdapter` is applied to the Collection as a whole.

The JAXB strategy leads to a simpler code base as only the object in question requires a transformer and the same transformer can be applied to a single field or a collection.
The JSONB strategy requires separate adapters for single instances and for collections.

This request is that the JsonbTypeAdapter processor is adjusted to also recognize collections. For example:

Example class code:
```java
@JsonbTypeAdapter(JsonMyObjectAdapter.class)
private Collection myObjects;
```

Current JSONB adapter code pattern:
```java
public class JsonMyObjectAdapter implements JsonbAdapter, String> {
...
```

Desired JSONB adapter code pattern:
```java
public class JsonMyObjectAdapter implements JsonbAdapter {
...
```

Contributor guide

Open the contributing guide

Research direction

Start by locating the JsonbTypeAdapter processor and tracing how it handles collection-valued fields; compare that behavior with JAXB's XmlJavaTypeAdapter semantics. Verify the change with coverage for adapters on individual objects and collection elements, and consider the work done when the collection example uses a MyObject adapter for each entry without breaking single-value adapters.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.