One of the .avsc file I use is an array of 7 top level JSon objects,
starting with:
[
{"name": "com.rr.avro.Fixed16", "type": "fixed", "size":16},
{"name": "com.rr.avro.Fixed4", "type": "fixed", "size":4},
{"name": "com.rr.avro.Variable", "type": "record", "fields": [
{"name": "variableId", "type": "int"},
{"name": "selectedValue", "type": "string"}]
},
. . .
And it works fine that way with the Java specific compiler. I avoid
having to define items the first time they are encountered this way.
Perhaps they won't with other languages?
On 3/11/11 10:59 AM, "Doug Cutting" <[email protected]> wrote:
>On 03/11/2011 10:28 AM, Scott Carey wrote:
>> You need an array of JSON objects in the avsc file, something like:
>
>An .avsc file can only contain a single top-level JSON object, not an
>array. So, if you wanted to define this in an .avsc file then you'd
>need to use a nested definition, like:
>
>------------
>
>{
> "namespace": "def.note.pad",
> "type": "record",
> "name": "Page",
> "doc": "Object definition of a Page composed of alphabet",
> "fields": [
> {
> "name": "letter",
> "type": {
> "type": "enum",
> "namespace": "def.al.pha.bet",
> "name": "KnownLetters",
> "doc": "Specifies known types of letters",
> "symbols": ["A", "B", "C", "D", "E"]
> }
> }
> ]
>}
>
>-------------
>
>Or you can use a .avpr file to define dependent types, like:
>
>-------------
>{ "protocol": "Foo",
> "namespace": "def.al.pha.bet",
> "types": [
> {
> "type": "enum",
> "name": "KnownLetters",
> "doc": "Specifies known types of letters",
> "symbols": ["A", "B", "C", "D", "E"]
> },
> {
> "namespace": "def.note.pad",
> "type": "record",
> "name": "Page",
> "doc": "Object definition of a Page composed of alphabet",
> "fields": [
> {"name": "letter", "type": "KnownLetters"}
> ]
> }
> ]
>}
>------------
>
>Doug