in src/main/java/com/epam/eco/commons/avro/AvroUtils.java [190:210]
public static GenericRecord decodeRecordFromJson(
String recordJson,
Schema schema,
boolean specific) {
Validate.notBlank(recordJson, "Record JSON is blank");
Validate.notNull(schema, "Schema is null");
try {
Decoder decoder = DecoderFactory.get().jsonDecoder(schema, recordJson);
DatumReader<Object> reader;
if (specific) {
reader = new SpecificDatumReader<>(schema);
} else {
reader = new GenericDatumReader<>(schema);
}
return (GenericRecord) reader.read(null, decoder);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}