@Test public void testSerialize() throws Exception { List<Tag> tags = new ArrayList<>(); tags.add(new Tag("tag1")); tags.add(new Tag("tag2")); tags.add(new Tag("tag3")); SampleClass sample = new SampleClass(); sample.setTags(tags); ObjectMapper mapper = new ObjectMapper(); assertEquals("{\"tags\":\"tag1,tag2,tag3\"}", mapper.writeValueAsString(sample)); }
@Override public void serialize(List<Tag> value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if(value != null && !value.isEmpty()) { StringBuilder sb = new StringBuilder(); for(int i = 0; i < value.size(); i++) { Tag tag = value.get(i); sb.append(tag.getTagText()); if(i != value.size() - 1) sb.append(","); } jgen.writeString(sb.toString()); } else { jgen.writeString(""); } }
TagsSerializer extends StdSerializer<List<Tag>> { @Override public void serialize(List<Tag> value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if(value != null && !value.isEmpty()) { StringBuilder sb = new StringBuilder(); for(int i = 0; i < value.size(); i++) { Tag tag = value.get(i); sb.append(tag.getTagText()); if(i != value.size() - 1) sb.append(","); } jgen.writeString(sb.toString()); } else { jgen.writeString(""); } } }
TagsSerializer extends StdSerializer<List<Tag>> { @Override public void serialize(List<Tag> value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if(value != null && !value.isEmpty()) { StringBuilder sb = new StringBuilder(); for(int i = 0; i < value.size(); i++) { Tag tag = value.get(i); sb.append(tag.getTagText()); if(i != value.size() - 1) sb.append(","); } jgen.writeString(sb.toString()); } else { jgen.writeString(""); } } TagsSerializer(); }
TagsSerializer extends StdSerializer<List<Tag>> { @Override public void serialize(List<Tag> value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if(value != null && !value.isEmpty()) { StringBuilder sb = new StringBuilder(); for(int i = 0; i < value.size(); i++) { Tag tag = value.get(i); sb.append(tag.getTagText()); if(i != value.size() - 1) sb.append(","); } jgen.writeString(sb.toString()); } else { jgen.writeString(""); } } TagsSerializer(); @Override void serialize(List<Tag> value, JsonGenerator jgen,
			SerializerProvider provider); }
TagsSerializer extends StdSerializer<List<Tag>> { @Override public void serialize(List<Tag> value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if(value != null && !value.isEmpty()) { StringBuilder sb = new StringBuilder(); for(int i = 0; i < value.size(); i++) { Tag tag = value.get(i); sb.append(tag.getTagText()); if(i != value.size() - 1) sb.append(","); } jgen.writeString(sb.toString()); } else { jgen.writeString(""); } } TagsSerializer(); @Override void serialize(List<Tag> value, JsonGenerator jgen,
			SerializerProvider provider);  }