avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh <jof...@gmail.com>
Subject How to encode arbitrary Json as Avro
Date Mon, 12 Oct 2015 15:21:38 GMT
Hi,

I want to have a field in my schema which allows arbitrary Json data.

One option is to just encode the Json as a string:

{ "name": “ my_json_field”, "type": "string" }

But I'd rather encode the Json fields more efficiently. I saw that Avro
provides some kind of support for encoding arbitrary Json, via the schema
given here -
https://svn.apache.org/repos/asf/avro/trunk/share/schemas/org/apache/avro/data/Json.avsc


It would be nice if I could use this in my own schema, e.g. like this:

{ "name": “my_json_field”, "type": "org.apache.avro.data.Json” }

Has anyone done anything like this before?

Ultimately I want to be able to construct my Avro object in Java:

JsonNode node = /* Use Jackson mapper to parse JsonNode from String */

MyAvroType avro = MyAvroType.newBuilder().setMyJsonField(node).build();

Thanks for any advice on this,

Josh

Mime
View raw message