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-api/src/main/java/com/juick/api/TGBot.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'juick-api') diff --git a/juick-api/src/main/java/com/juick/api/TGBot.java b/juick-api/src/main/java/com/juick/api/TGBot.java index 882dc821..e0ab3e1e 100644 --- a/juick-api/src/main/java/com/juick/api/TGBot.java +++ b/juick-api/src/main/java/com/juick/api/TGBot.java @@ -1,5 +1,6 @@ package com.juick.api; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; import com.juick.service.MessagesService; import com.juick.service.TelegramService; @@ -35,19 +36,26 @@ public class TGBot implements AutoCloseable { TelegramBot bot; WebSocket ws; - ObjectMapper ms = new ObjectMapper(); + private ObjectMapper ms; @Inject TelegramService telegramService; @Inject MessagesService messagesService; + private TGBot() { + throw new IllegalStateException(); + } public TGBot(String token) { if (StringUtils.isBlank(token)) { return; } bot = TelegramBotAdapter.build(token); + ms = new ObjectMapper(); + ms.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); + ms.setSerializationInclusion(JsonInclude.Include.NON_NULL); + ms.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); try { SetWebhook webhook = new SetWebhook().url("https://api.juick.com/tlgmbtwbhk"); if (!bot.execute(webhook).isOk()) { -- cgit v1.2.3