Allow to suppress null values in serialization

オープン
#51 コメント 3 件 リアクション 3 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@Inf1mum がすでに取り組んでいます。

2026年11月10日 から。

  • #223 @Inf1mum による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
java
領域
api, backend

調査の方向性

まず JsonNullableSerializer と JsonNullableModule を読んで suppressNull が現在どのように扱われているかを理解し、その後、リポジトリに既存のシリアライズテストを確認します。変更によってシリアライザーが ObjectMapper の Include.NON_NULL 設定を尊重するようにするのか、モジュールレベルの切り替えを追加するのかを定義し、選択した動作がテストでカバーされた時点で作業完了とします。

索引モデルが issue の本文から書いたものです。

説明

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?

主要言語
Java
スター
158
フォーク
47
平均マージ
3日 7時間
マージ済み PR(30日)
5

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

OpenAPITools/jackson-databind-nullable のほかの issue

OpenAPITools/jackson-databind-nullable の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。