Closed suguanYang closed 1 year ago
I have a data object like this:
const person = { name: 'John', age: 30, address1: 'xxxx', address2: 'xxxx', address3: 'xxxx', }
the question is how to support the fields address${number} in schema definition?
address${number}
const type = avsc.Type.forSchema({ name: 'PersonList', type: 'array', items: { name: 'Person', type: 'record', fields: [ { name: 'name', type: 'string' }, { name: 'age', type: 'int' }, ] } });
Hi @suguanYang. AFAIK Avro doesn't allow arbitrary keys in records so you'll need to use a map. If possible, I'd recommend splitting the addresses into their own map so you can tighten the values' type.
I have a data object like this:
the question is how to support the fields
address${number}
in schema definition?