Search in sources :

Example 1 with AvroFactory

use of com.fasterxml.jackson.dataformat.avro.AvroFactory in project jvm-serializers by eishay.

the class JacksonAvroDatabind method register.

public static void register(TestGroups groups) {
    ObjectMapper mapper = new ObjectMapper(new AvroFactory());
    mapper.enable(SerializationFeature.WRITE_ENUMS_USING_INDEX);
    JavaType type = mapper.constructType(MediaContent.class);
    AvroSchema schema = new AvroSchema(Avro.Media.sMediaContent);
    ObjectReader reader = mapper.readerFor(type).with(schema);
    ObjectWriter writer = mapper.writerFor(type).with(schema);
    groups.media.add(JavaBuiltIn.mediaTransformer, new StdJacksonDataBind<MediaContent>("avro/jackson/databind", type, mapper, reader, writer), new SerFeatures(SerFormat.JSON, SerGraph.FLAT_TREE, SerClass.ZERO_KNOWLEDGE, ""));
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) AvroFactory(com.fasterxml.jackson.dataformat.avro.AvroFactory) AvroSchema(com.fasterxml.jackson.dataformat.avro.AvroSchema) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) MediaContent(data.media.MediaContent) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

JavaType (com.fasterxml.jackson.databind.JavaType)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)1 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 AvroFactory (com.fasterxml.jackson.dataformat.avro.AvroFactory)1 AvroSchema (com.fasterxml.jackson.dataformat.avro.AvroSchema)1 MediaContent (data.media.MediaContent)1