diff options
author | Vitaly Takmazov | 2016-11-28 14:37:02 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-11-28 14:37:02 +0300 |
commit | 5b2bd7f928bbf9d3233ff029ed5c09ac46daf0de (patch) | |
tree | cfad7f15e35c51d11a488df5a9b2be5300b9af54 /juick-api/src/main/java/com/juick/api | |
parent | c252087c54e91e63f89775eba4c65cf87ae21e5d (diff) |
all components using jackson now, org.json serializer moved to compatibility tests package
Diffstat (limited to 'juick-api/src/main/java/com/juick/api')
-rw-r--r-- | juick-api/src/main/java/com/juick/api/TGBot.java | 9 |
1 files changed, 4 insertions, 5 deletions
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); |