Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public void customize(GsonBuilder builder) {
.toCall(builder::generateNonExecutableJson);
map.from(properties::getExcludeFieldsWithoutExposeAnnotation)
.toCall(builder::excludeFieldsWithoutExposeAnnotation);
map.from(properties::getSerializeNulls).toCall(builder::serializeNulls);
map.from(properties::getSerializeNulls).whenTrue()
.toCall(builder::serializeNulls);
map.from(properties::getEnableComplexMapKeySerialization)
.toCall(builder::enableComplexMapKeySerialization);
map.from(properties::getDisableInnerClassSerialization)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,23 @@ public void excludeFieldsWithoutExposeAnnotation() {
}

@Test
public void serializeNulls() {
public void serializeNullsTrue() {
this.contextRunner.withPropertyValues("spring.gson.serialize-nulls:true")
.run((context) -> {
Gson gson = context.getBean(Gson.class);
assertThat(gson.serializeNulls()).isTrue();
});
}

@Test
public void serializeNullsFalse() {
this.contextRunner.withPropertyValues("spring.gson.serialize-nulls:false")
.run((context) -> {
Gson gson = context.getBean(Gson.class);
assertThat(gson.serializeNulls()).isFalse();
});
}

@Test
public void enableComplexMapKeySerialization() {
this.contextRunner
Expand Down