package org.lilycms.util.json;

import org.codehaus.jackson.*;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.MappingJsonFactory;
import org.codehaus.jackson.map.ObjectMapper;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class JsonFormat {
    public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
    public static final MappingJsonFactory JSON_FACTORY;
    static {
        JSON_FACTORY = new MappingJsonFactory();
        JSON_FACTORY.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
        JSON_FACTORY.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
        JSON_FACTORY.getCodec().getDeserializationConfig().enable(DeserializationConfig.Feature.USE_BIG_DECIMAL_FOR_FLOATS);
    }

    public static void serialize(JsonNode jsonNode, OutputStream outputStream) throws IOException {
        OBJECT_MAPPER.writeValue(outputStream, jsonNode);
    }

    public static byte[] serializeAsBytes(JsonNode jsonNode) throws IOException {
        return OBJECT_MAPPER.writeValueAsBytes(jsonNode);
    }

    public static JsonNode deserialize(InputStream inputStream) throws IOException {
        JsonParser jp = JSON_FACTORY.createJsonParser(inputStream);
        return jp.readValueAsTree();
    }

    public static JsonNode deserialize(byte[] data) throws IOException {
        JsonParser jp = JSON_FACTORY.createJsonParser(data);
        return jp.readValueAsTree();
    }
}

@@ -210,16 +210,53 @@
 apper;%0A%0A
+import java.io.ByteArrayInputStream;%0A
 import j
@@ -1250,102 +1250,49 @@
     
-JsonParser jp = JSON_FACTORY.createJsonParser(inputStream);%0A        return jp.readValueAsTree(
+return OBJECT_MAPPER.readTree(inputStream
 );%0A 
@@ -1382,95 +1382,68 @@
     
-JsonParser jp = JSON_FACTORY.createJsonParser(data);%0A        return jp.readValueAsTree(
+return OBJECT_MAPPER.readTree(new ByteArrayInputStream(data)
 );%0A 

Implement JsonFormat.deserialize also using ObjectMapper. Just cleanup, does not make a real difference (except for null values which return a null node).