Allow to suppress null values in serialization

Open
#51 3 comments 3 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@Inf1mum is already working on this.

Since Nov 10, 2026.

  • #223 by @Inf1mum — open

Assessment

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

Research direction

Start by reading JsonNullableSerializer and JsonNullableModule to understand how suppressNull is currently handled, then inspect the repository's existing serialization tests. Define whether the change should make the serializer respect ObjectMapper's Include.NON_NULL setting or add a module-level toggle, and consider the work done when the chosen behavior is covered by tests.

Written by the indexing model from the issue text.

Description

In order to minimize my response body size from my REST controllers, I would like to be able to supress all null values when serializing to JSON, however when I changed my ObjectMapper to use Include.NON_NULL by default I found that suppressNull is hard coded to false in JsonNullableSerializer. This results in considerable bloat.

You might wonder why I don't use JsonNullable.undefined() instead. I have an OpenAPI schema with 679 different fields, of which 174 are nullable. Keeping track of which fields are nullable, and changing all of those converter classes to use JsonNullable is quite a lot of work. On top of that, the Java models generated with openapi-generator-maven-plugin do not create fluent setters for JsonNullable.

It would save me a lot of effort if JsonNullableSerializer would just respect suppressNull, is that something you would agree to change?
If not, I could submit a PR to add a setting to JsonNullableModule to toggle whether suppressNull should be respected?

Dominant language
Java
Stars
158
Forks
47
Avg merge
1d 13h
Merged PRs (30d)
3

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from OpenAPITools/jackson-databind-nullable

All issues in OpenAPITools/jackson-databind-nullable

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.