private static void checkJson(Schema schema, Object datum,
DatumWriter<Object> writer,
DatumReader<Object> reader)
throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Encoder encoder = new JsonEncoder(schema, out);
writer.setSchema(schema);
writer.write(datum, encoder);
writer.write(datum, encoder);
encoder.flush();
byte[] data = out.toByteArray();
reader.setSchema(schema);
Decoder decoder = new JsonDecoder(schema, new ByteArrayInputStream(data));
Object decoded = reader.read(null, decoder);