Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Integrating Thrift's JSON serializer with Jackson
class ThriftSerializer extends JsonSerializer<TBase> {
public void serialize(TBase value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
try {
TProtocolFactory f = new TSimpleJSONProtocol.Factory();
String s = new TSerializer(f).toString(value);
catch (TException e) {
throw new IOException(e);
ObjectMapper objectMapper = new ObjectMapper();
CustomSerializerFactory serializerFactory = new CustomSerializerFactory();
serializerFactory.addGenericMapping(TBase.class, new ThriftSerializer());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.