jakartaee / jakartaee/jsonb-api

@JsonbProperty on boolean field not resolved correctly

Open
#252 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

I'm migrating from JAX-B (+Jackson Binding) to JSON-B (Yasson) and found a possible issue concerning the processing of the @JsonbProperty(value = "...") in some special cases.

Simplified I have POJOs with the following:

	@JsonbProperty(value = "myBool")
	private boolean isSomething;

	public boolean isSomething() {
		return isSomething;
	}

	public void setSomething(boolean isSomething) {
		this.isSomething = isSomething;
	}

The getter and setter are generated automatically by the IDE or lombok in this way. In this case, the getter is named in the same way as the field (isSomething) as you see.

When I process that with Yasson, I get something like this:
{..., "something":true, ...}

But I want it to be
{..., "myBool":true, ...}

Bug or Feature?

I attached some test to reproduce it.

SamplePojo.java.txt
SamplePojoTest.java.txt
pom.xml.txt

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 with the attached SamplePojo.java.txt and SamplePojoTest.java.txt, using pom.xml.txt to identify the JSON-B/Yasson setup. Run the reproduction and inspect how the boolean field and accessor are resolved. Done means serialization uses the @JsonbProperty value "myBool" instead of "something".

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.