Description
Writer schema:
{ "type": "record", "name": "TestRecord", "fields": [ { "name": "array", "type": { "type": "array", "items": { "name": "item", "type": "record", "fields": [ { "name": "A", "type": "string" }, { "name": "B", "type": "string", "default": "foo" } ] } } } ] }
Reader schema:
{ "type": "record", "name": "TestRecord", "fields": [ { "name": "array", "type": { "type": "array", "items": { "name": "item", "type": "record", "fields": [ { "name": "A", "type": "string" } ] } } } ] }
Data is:
{ "array": [ { "A": "", "B": "" } ] }
The following code fails with an exception “Expected: Repeater got String”. The equivalent java code works fine on the same schema and data.
auto decoder = avro::resolvingDecoder(writerSchema, readerSchema, avro::jsonDecoder(writerSchema)); strinstream ss = loadData(); auto_ptr<avro::InputStream> in = avro::istreamInputStream(ss); decoder->init(*in); auto record = reader::TestRecord(); decode(*decoder, record);
I stepped through the code and what seems to be happening is that the code is treating “A” and “B” as distinct elements in the array, as if the array had two elements rather than one.
I'm not sure how to go about fixing this. Any pointers would be appreciated. (I don't think it's my C++ test code. It works fine if the record above isn't in an array.)