From b4225fa075eef58924399f2c5f7a117ee171c2c6 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 28 Nov 2016 14:49:47 +0300 Subject: configure json serialization properties --- .../src/main/java/com/juick/components/Notifications.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'juick-notifications/src/main') diff --git a/juick-notifications/src/main/java/com/juick/components/Notifications.java b/juick-notifications/src/main/java/com/juick/components/Notifications.java index e0155a0a..dac4d22e 100644 --- a/juick-notifications/src/main/java/com/juick/components/Notifications.java +++ b/juick-notifications/src/main/java/com/juick/components/Notifications.java @@ -17,6 +17,7 @@ */ package com.juick.components; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.android.gcm.server.*; import com.juick.components.mpns.MPNSError; @@ -88,6 +89,9 @@ public class Notifications implements AutoCloseable { xmppPort = NumberUtils.toInt(env.getProperty("xmpp_port"), 5347); xmppPushPassword = env.getProperty("push_xmpp_password", ""); mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); } @PostConstruct @@ -120,6 +124,9 @@ public class Notifications implements AutoCloseable { if (!regids.isEmpty()) { try { ObjectMapper messageSerializer = new ObjectMapper(); + messageSerializer.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); + messageSerializer.setSerializationInclusion(JsonInclude.Include.NON_NULL); + messageSerializer.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); String json = messageSerializer.writeValueAsString(jmsg); logger.info(json); Message message = new Message.Builder().addData("message", json).build(); -- cgit v1.2.3