OK, I think I got my final version, do let me know if you spot anything
wrong with it:
public static final ObjectMapper GZIP_SMILE_MAPPER;
public static final Charset UTF8=Charset.forName("UTF-8");
static{
final SmileFactory smileFactory=new
SmileFactory().disable(ENCODE_BINARY_AS_7BIT);
smileFactory.setInputDecorator(new InputDecorator()
{
@Override
public InputStream decorate(IOContext context,InputStream
inputStream) throws IOException
{
return new GZIPInputStream(inputStream);
}
@Override
public InputStream decorate(IOContext context,byte[] bytes,int
offset,int length) throws IOException
{
return new GZIPInputStream(new
ByteArrayInputStream(bytes,offset,length));
}
@Override
public Reader decorate(IOContext ioContext,Reader reader) throws
IOException
{
return new InputStreamReader(new GZIPInputStream(new
ReaderInputStream(reader)),UTF8);
}
});
smileFactory.setOutputDecorator(new OutputDecorator()
{
@Override
public OutputStream decorate(IOContext context,OutputStream
outputStream) throws IOException
{
return new GZIPOutputStream(outputStream);
}
@Override
public Writer decorate(IOContext context,Writer writer) throws
IOException
{
return new OutputStreamWriter(new GZIPOutputStream(new
WriterOutputStream(writer,UTF8)));
}
});
GZIP_SMILE_MAPPER=new ObjectMapper(smileFactory).
disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).
disable(SerializationFeature.FAIL_ON_EMPTY_BEANS).
setSerializationInclusion(JsonInclude.Include.NON_NULL).
disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).
registerModule(INT_RANGE_MODULE).
registerModule(JODA_MODULE).
registerModule(TAGS_MODULE);
}
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.