Apache Avro JSON Decoder for List/Array of Avro Objects

I couldn’t find a good example of decoding a JSON string that’s a list/array of Avro objects on the web. I just wanted to write a post to say that it works.

Here’s a few high level things that I remember

  • Create a JSON Decoder with Schema.createArray({avroObject}.getSchema())
  • When initializing the data reader, use List<{avroObject}> and also pass in an initialized instance of List<{avroObject}> along with the JSON Decoder created above.

It should work, but I had to use the debugger a few times to clear out some JSON issues.  I hope this helps – I spent a lot of unnecessary time checking whether something like this would work.  It looks like it’s supported out of the box.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s