From 5f1f592f5fada11056cb3e5471280d8e5b0e826e Mon Sep 17 00:00:00 2001 From: Jorge Bescos Gascon Date: Fri, 1 Oct 2021 14:17:17 +0200 Subject: [PATCH] introduce null-save JsonObjectBuilder.add and JsonGenerator.write methods #213 Signed-off-by: Jorge Bescos Gascon --- api/src/main/java/jakarta/json/JsonConfig.java | 6 ++++++ api/src/main/java/jakarta/json/JsonObjectBuilder.java | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/jakarta/json/JsonConfig.java b/api/src/main/java/jakarta/json/JsonConfig.java index 49c794b8..8b7c2594 100644 --- a/api/src/main/java/jakarta/json/JsonConfig.java +++ b/api/src/main/java/jakarta/json/JsonConfig.java @@ -23,6 +23,12 @@ */ public final class JsonConfig { + /** + * Configuration property to ignore null values. All providers + * must support this property. The value of the property is boolean. + */ + public static final String IGNORE_NULL = "jakarta.json.JsonConfig.ignoreNull"; + /** * Configuration property to define the strategy for handling duplicate keys. * diff --git a/api/src/main/java/jakarta/json/JsonObjectBuilder.java b/api/src/main/java/jakarta/json/JsonObjectBuilder.java index 6ada9abc..bed859d9 100644 --- a/api/src/main/java/jakarta/json/JsonObjectBuilder.java +++ b/api/src/main/java/jakarta/json/JsonObjectBuilder.java @@ -86,8 +86,9 @@ * * * - *

This class does not allow null to be used as a name or - * value while building the JSON object + *

By default, this class does not allow null to be used as a name or + * value while building the JSON object. It is possible to change this behavior with configuration + * {@link JsonConfig#IGNORE_NULL} * * @see JsonArrayBuilder */