Search in sources :

Example 1 with UTF8JsonGenerator

use of com.fasterxml.jackson.core.json.UTF8JsonGenerator in project neo4j by neo4j.

the class StreamingJsonFormat method createJsonFactory.

private static JsonFactory createJsonFactory() {
    final ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.disable(FLUSH_AFTER_WRITE_VALUE);
    JsonFactory factory = new JsonFactory(objectMapper) {

        @Override
        protected JsonGenerator _createUTF8Generator(OutputStream out, IOContext ctxt) {
            final int bufferSize = 1024 * 8;
            UTF8JsonGenerator gen = new UTF8JsonGenerator(ctxt, _generatorFeatures, _objectCodec, out, DEFAULT_QUOTE_CHAR, new byte[bufferSize], 0, true);
            if (_characterEscapes != null) {
                gen.setCharacterEscapes(_characterEscapes);
            }
            return gen;
        }
    };
    factory.disable(JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM);
    return factory;
}
Also used : UTF8JsonGenerator(com.fasterxml.jackson.core.json.UTF8JsonGenerator) OutputStream(java.io.OutputStream) JsonFactory(com.fasterxml.jackson.core.JsonFactory) IOContext(com.fasterxml.jackson.core.io.IOContext) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 IOContext (com.fasterxml.jackson.core.io.IOContext)1 UTF8JsonGenerator (com.fasterxml.jackson.core.json.UTF8JsonGenerator)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 OutputStream (java.io.OutputStream)1