Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Json tp AVRO with org.apache.avro.data

$
0
0
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 [ at ] 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

Viewing all articles
Browse latest Browse all 5648

Trending Articles