From bdbf65e0a50758bfcc88e1cc9c501eeed4e7e45d Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 12 Jul 2016 17:39:33 +0300 Subject: jackson-databind WIP --- juick-core/src/main/java/com/juick/json/MessageSerializer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'juick-core/src/main/java/com/juick/json') diff --git a/juick-core/src/main/java/com/juick/json/MessageSerializer.java b/juick-core/src/main/java/com/juick/json/MessageSerializer.java index 4238df60..d5adfa6e 100644 --- a/juick-core/src/main/java/com/juick/json/MessageSerializer.java +++ b/juick-core/src/main/java/com/juick/json/MessageSerializer.java @@ -18,6 +18,7 @@ package com.juick.json; import com.juick.Message; +import com.juick.Tag; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -27,6 +28,7 @@ import java.text.SimpleDateFormat; import java.util.TimeZone; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.stream.Collectors; /** * @@ -68,7 +70,7 @@ public class MessageSerializer extends JSONSerializer { if (json.has("tags")) { JSONArray tags = json.getJSONArray("tags"); for (int n = 0; n < tags.length(); n++) { - jmsg.Tags.add(tags.getString(n).replace(""", "\"")); + jmsg.Tags.add(new Tag(tags.getString(n).replace(""", "\""))); } } @@ -113,7 +115,7 @@ public class MessageSerializer extends JSONSerializer { json.put("user", userSerializer.serialize(msg.getUser())); } if (msg.Tags != null && msg.Tags.size() > 0) { - json.put("tags", new JSONArray(msg.Tags)); + json.put("tags", new JSONArray(msg.Tags.stream().map(Tag::getName).collect(Collectors.toList()))); } if (msg.Replies > 0) { json.put("replies", msg.Replies); -- cgit v1.2.3