From f04b1c21e42525377d01b5d102006ae4efe5d4b1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 12 Jul 2016 17:51:27 +0300 Subject: jackson-databind serialization with tests --- juick-core/src/main/java/com/juick/Message.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'juick-core/src/main/java/com') diff --git a/juick-core/src/main/java/com/juick/Message.java b/juick-core/src/main/java/com/juick/Message.java index 2b66e667..cb5fe92e 100644 --- a/juick-core/src/main/java/com/juick/Message.java +++ b/juick-core/src/main/java/com/juick/Message.java @@ -17,6 +17,8 @@ */ package com.juick; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.*; @@ -36,6 +38,7 @@ public class Message implements Comparable { public int ReplyTo = 0; private String Text = null; private User User = null; + @JsonProperty("tags") public List Tags = new ArrayList<>(); private Date date; public int TimeAgo = 0; @@ -157,7 +160,7 @@ public class Message implements Comparable { return null; } } - + @JsonIgnore public String getTagsString() { String ret = ""; if (!Tags.isEmpty()) { @@ -209,6 +212,7 @@ public class Message implements Comparable { User = user; } + @JsonProperty("body") public String getText() { return Text; } @@ -217,6 +221,8 @@ public class Message implements Comparable { Text = text; } + @JsonProperty("timestamp") + @JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss", timezone="UTC") public Date getDate() { return date; } -- cgit v1.2.3