avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Rosenstrauch <dar...@darose.net>
Subject Re: Schema for array of records
Date Mon, 21 Mar 2011 15:42:38 GMT
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