From 5b2bd7f928bbf9d3233ff029ed5c09ac46daf0de Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 28 Nov 2016 14:37:02 +0300 Subject: all components using jackson now, org.json serializer moved to compatibility tests package --- juick-api/src/main/java/com/juick/api/TGBot.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'juick-api/src/main/java/com') 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 ae3c6b74..882dc821 100644 --- a/juick-api/src/main/java/com/juick/api/TGBot.java +++ b/juick-api/src/main/java/com/juick/api/TGBot.java @@ -1,6 +1,6 @@ package com.juick.api; -import com.juick.json.MessageSerializer; +import com.fasterxml.jackson.databind.ObjectMapper; import com.juick.service.MessagesService; import com.juick.service.TelegramService; import com.neovisionaries.ws.client.WebSocket; @@ -16,7 +16,6 @@ import com.pengrad.telegrambot.request.SendMessage; import com.pengrad.telegrambot.request.SetWebhook; import com.pengrad.telegrambot.response.SendResponse; import org.apache.commons.lang3.StringUtils; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,7 +35,7 @@ public class TGBot implements AutoCloseable { TelegramBot bot; WebSocket ws; - MessageSerializer ms = new MessageSerializer(); + ObjectMapper ms = new ObjectMapper(); @Inject TelegramService telegramService; @@ -71,8 +70,8 @@ public class TGBot implements AutoCloseable { @Override public void onTextMessage(WebSocket websocket, String text) throws Exception { super.onTextMessage(websocket, text); - com.juick.Message jmsg = ms.deserialize(new JSONObject(text)); - logger.info("got jmsg: " + ms.serialize(jmsg).toString()); + com.juick.Message jmsg = ms.readValue(text, com.juick.Message.class); + logger.info("got jmsg: " + ms.writeValueAsString(jmsg)); String msgUrl = formatUrl(jmsg); if (jmsg.getRid() == 0) { String msg = formatPost(jmsg); -- cgit v1.2.3