jakartaee / jakartaee/jsonb-api

Add JsonbAccessorType class annotation

Open
#256 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
95
Forks
41
Avg merge
1d 6h
Merged PRs (30d)
35

Description

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...)

```java
@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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing JSON-B API annotations and access or visibility strategy, then compare their behavior with the referenced XmlAccessorType and XmlAccessType annotations. Done should provide a class-level JsonbAccessorType and JsonbAccessType.FIELD behavior that excludes methods such as isValid without requiring JsonbTransient annotations.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.