Учитывая, что у меня есть действующая схема avro, как показано ниже:
{
"type": "record",
"namespace": "com.example",
"name": "Employee",
"doc": "Avro Schema for our Employee",
"fields": [
{ "name": "first_name", "type": "string", "doc": "First Name of Customer" },
{ "name": "last_name", "type": "string", "doc": "Last Name of Customer" },
{ "name": "age", "type": "int", "doc": "Age at the time of registration" },
]
}
и массив Json, как показано ниже:
[
{
"first_name": "Alex",
"last_name": "Dan",
"age": 35
},
{
"first_name": "Bill",
"last_name": "Lee",
"age": 36
},
{
"first_name": "Charan",
"last_name": "Vaski",
"age": 37
}
]
Каков наилучший эффективный способ преобразования массива json в список Avro GenericRecord?
У меня есть следующие коды, которые преобразуют один объект json в один GenericRecord
Schema schema = parser.parse(schemaString);
GenericDatumReader<GenericRecord> reader = new GenericDatumReader<>(schema);
JsonDecoder jsonDecoder = DecoderFactory.get().jsonDecoder(schema, jsonString);
GenericRecord record = reader.read(null, jsonDecoder);
System.out.println(record);