avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curtis Jensen <cur...@the-jensens.org>
Subject Re: Schema for array of records
Date Mon, 21 Mar 2011 16:43:03 GMT
Great.  However, how to use it?
I've modified my schema to look like below:

In java, when I try to parse this schema with:
Schema usersSchema = Schema.parse(USERS_SCHEMA);

I get an "org.apache.avro.SchemaParseException: No type" exception
(Here USERS_SCHEMA is the schema below).


{
 "name": "Users",
 "type": {
 "type": "array",
 "items": {
       "name": "User",
       "type": "record",
       "fields" : [
               {"name": "name", "type": "string"},
                {"name": "id", "type": "long"}
              ]
       }
   }
}

On Mon, Mar 21, 2011 at 8:42 AM, David Rosenstrauch <darose@darose.net> wrote:
> On 03/21/2011 11:28 AM, Curtis Jensen wrote:
>>
>> How does one create a schema for an array of records?
>>
>> For example, I have a record schema for a user (name and id; see
>> below).  I would like to serialize an array of users.  I've tried
>> various combinations of things, and I'm not getting it to work.
>>
>> Thanks,
>> Curtis
>>
>>
>>  [
>>  {
>>  "name": "User",
>>  "type": "record",
>>  "fields": [
>>    {"name": "name", "type": "string"},
>>    {"name": "id", "type": "int"}]
>>  },
>>  {
>>  "type": "array", "items": "User"
>>  }
>>  ]}
>
>
> We do it like so:
>
> "name": "AttributeMappings",
> "type": {
>        "type": "array",
>        "items": {
>                "name": "AttributeMapping",
>                "type": "record",
>                "fields" : [
>                        {"name": "Key", "type": "long"},
>                        {"name": "Value", "type": "long"}
>                ]
>        }
> }
>
> HTH,
>
> DR
>

Mime
View raw message