How to deserialize an Avro file using Jackson?

4k Views Asked by At

Avro can store batches of serialized object in a single file ("object container file"). Avro supports deserialization to avro-generated java classes or to java bean-style objects, which are both too restrictive in my opinion. I'd love to use Jackson for this, but I haven't found a way to do this yet.

Deserialization of a single object works great with jackson-dataformat-avro. The challenge seems to be in combining avro (for reading the file and parsing the meta-data) and jackson-dataformat-avro to deserialize each object in the file.

Does anyone know how to do this?

1

There are 1 best solutions below

0
On

Unfortunately Avro specifies slightly different format for Files than when sending content over the wire (serializing to other destinations). In former case, Avro schema is included (serialized as JSON). Currently (Jackson 2.9) this format is not yet supported.

It should be relatively easy to support, but not trivial, so hopefully it gets implemented. Issue is tracked here:

https://github.com/FasterXML/jackson-dataformats-binary/issues/8