OpenAPITools / OpenAPITools/jackson-databind-nullable

Deserialising an empty character as json null instead of json undefined

Open
#26 3 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
153
Forks
47
Avg merge
4d 15h
Merged PRs (30d)
6

Description

Recently we changed a type in one object from JsonNullable<String> sth = JsonNullable.undefined() to JsonNullable<Character> sth = JsonNullable.undefined(). Soon after we noticed a change in the deserialisation behaviour - explicit updates of that property to an empty string ("") no longer worked, as they were treated as not present (JsonNullable.undefined instead of JsonNullable[null]).

It seems that the issue is in the JsonNullableDeserializer, namely in the constructor:

this.isStringDeserializer = ((ReferenceType) fullType).getReferencedType().isTypeOrSubTypeOf(String.class);

Does it make sense to change the check and include Character as well as String? Or would you suggest another alternative? If it is the former, we can also open a PR, as the change doesn't seem so large (and there is already https://github.com/OpenAPITools/jackson-databind-nullable/pull/4 for inspiration).

Contributor guide

No contributing guide indexed for this repository

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 JsonNullableDeserializer constructor and inspect how isStringDeserializer is set for String and Character reference types. Compare the proposed change with pull request #4, then verify that deserialising an explicit empty string for JsonNullable produces a present null value rather than JsonNullable.undefined().

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.