Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1328 null properties in select #1337

Merged
merged 2 commits into from Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -60,7 +60,7 @@ private static synchronized void initObjectMapper() {

private static ObjectMapper createObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.ALWAYS);
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
mapper.disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE);

Expand Down
Expand Up @@ -26,6 +26,8 @@
import de.fraunhofer.iosb.ilt.frostserver.util.SimpleJsonMapper;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeAll;
Expand Down Expand Up @@ -62,6 +64,17 @@ void serialiseDate() throws IOException {
assertTrue(jsonEqual(expResult, result), "Date not serialised correctly.");
}

@Test
void serialiseEmptyProperties() throws IOException {
String expResult = "{\"foo\":\"bar\"}";
Map<String, String> props = new HashMap<>();
props.put("foo","bar");
props.put("nullable",null);
props.put("empty","");
final String result = JsonWriter.writeObject(props);
assertTrue(jsonEqual(expResult, result), "Empty properties not serialised correctly: " + result);
}

@Test
void deSerialiseDate() throws IOException {
String input = "\"1987-06-05\"";
Expand Down