You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Alexey Yakubovich <al...@yahoo.com> on 2014/04/27 04:28:16 UTC
Json tp AVRO with org.apache.avro.data
Hi,
I read the exchange on this topic on avro-user mailing list archives: September 2012 (http://mail-archives.apache.org/mod_mbox/avro-user/201209.mbox/%3C445E44A6-345F-42FC-B340-48AF3804A93D@braindump.ms%3E)
I am sorry if that suppose to be obvious, but I still don't understand how to use the org.apache.avro.data.Json, and Json.Writer classes.
Particularly, how to map JSON doc. fields to AVRO schema fields.
Suppose I have a simple JSON doc:
{
"id" : "abc123",
"width" : 1.3
"details":
{
"id" : "XXX#11"
"len" : 20
}
}
Now, suppose I want AVRO schema something like:
{"namespace" : "exam",
"type": "record",
"name": "avro-meme",
"fields" : [ {"name" : "id", "type ": "string"},
{"name" : "width", "type": "double"},
{"name" : "details",
"type" : {
"type" : "record",
"name" : "abra",
"fields" : [
{"name" : "id", "type" : "string"},
{"name" : "len", "type" : "int" }
]
}
}
]
}
So how I specify json to avro mapping in org.apache.avro.data.Json , what are the rules of the game?
Or, if it is not how you suppose to use org.apache.avro.data.Json, then how?
Thank you
Alexey