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 --- juick-www/src/main/java/com/juick/www/FacebookLogin.java | 4 ++++ juick-www/src/main/java/com/juick/www/TwitterAuth.java | 4 ++++ juick-www/src/main/java/com/juick/www/VKontakteLogin.java | 9 ++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'juick-www/src') diff --git a/juick-www/src/main/java/com/juick/www/FacebookLogin.java b/juick-www/src/main/java/com/juick/www/FacebookLogin.java index b42bb23b..34385a3d 100644 --- a/juick-www/src/main/java/com/juick/www/FacebookLogin.java +++ b/juick-www/src/main/java/com/juick/www/FacebookLogin.java @@ -17,6 +17,7 @@ */ package com.juick.www; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; import com.juick.server.UserQueries; import com.juick.www.facebook.Graph; @@ -52,6 +53,9 @@ public class FacebookLogin { this.FACEBOOK_APPID = ApplicationID; this.FACEBOOK_SECRET = secret; mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); } protected void doGet(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { diff --git a/juick-www/src/main/java/com/juick/www/TwitterAuth.java b/juick-www/src/main/java/com/juick/www/TwitterAuth.java index c6aaf9a1..65998ece 100644 --- a/juick-www/src/main/java/com/juick/www/TwitterAuth.java +++ b/juick-www/src/main/java/com/juick/www/TwitterAuth.java @@ -1,5 +1,6 @@ package com.juick.www; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.scribejava.apis.TwitterApi; import com.github.scribejava.core.builder.ServiceBuilder; @@ -32,6 +33,9 @@ public class TwitterAuth { this.consumerKey = consumerKey; this.consumerSecret = consumerSecret; mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); } protected void doGet(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) diff --git a/juick-www/src/main/java/com/juick/www/VKontakteLogin.java b/juick-www/src/main/java/com/juick/www/VKontakteLogin.java index 83619b2a..1ccf36b6 100644 --- a/juick-www/src/main/java/com/juick/www/VKontakteLogin.java +++ b/juick-www/src/main/java/com/juick/www/VKontakteLogin.java @@ -17,6 +17,7 @@ */ package com.juick.www; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; import com.juick.server.UserQueries; import com.juick.www.vk.*; @@ -43,7 +44,13 @@ public class VKontakteLogin { private static final String VK_SECRET = "z2afNI8jA5lIpZ2jsTm1"; private static final String VK_REDIRECT = "http://juick.com/_vklogin"; - private final ObjectMapper mapper = new ObjectMapper(); + public VKontakteLogin() { + mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); + } + private final ObjectMapper mapper; protected void doGet(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String code = request.getParameter("code"); -- cgit v1.2.3