Convert Avro to JSON
Twister pairs nicely with Jackson’s ObjectMapper
since they both use POJOs.
Encode Avro Records to a JSON String
GenericRecord avroRecord = ...;
Map<String, Object> personMap = new AvroWrapper().wrap(avroRecord);
String jsonString = new ObjectMapper().writeValueAsString(personMap);
Convert Avro Record Bytes to a JSON String
Schema avroSchema = ...;
ByteBuffer avroBytes = ...;
Map<String, Object> personMap = new AvroReader().read(avroBytes, avroSchema);
String jsonString = new ObjectMapper().writeValueAsString(personMap);