package org.apache.flume.serialization;

import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import java.io.IOException;

public class JSONStringSerializer {

    private static ObjectMapper mapper = new ObjectMapper();

    static {
        mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_EMPTY);
        mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
    }

    private JSONStringSerializer() {
        // nothing to do, really
    }

    public static String toJSONString(Object object) throws IOException {
        return mapper.writeValueAsString(object);
    }

    public static <T> T fromJSONString(String s, Class<T> clazz) throws IOException {
        return mapper.readValue(s, clazz);
    }

}

@@ -693,16 +693,21 @@
 String s
+tring
 , Class%3C
@@ -770,16 +770,21 @@
 dValue(s
+tring
 , clazz)
@@ -792,10 +792,273 @@
 %0A    %7D%0A%0A
+    public static byte%5B%5D toBytes(Object object) throws IOException %7B%0A        return mapper.writeValueAsBytes(object);%0A    %7D%0A%0A    public static %3CT%3E T fromBytes(byte%5B%5D bytes, Class%3CT%3E clazz) throws IOException %7B%0A        return mapper.readValue(bytes, clazz);%0A    %7D%0A
 %7D%0A

Add de/serialization from/to bytes