You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Kamesh Kompella <ka...@chooxy.com> on 2016/11/05 22:32:26 UTC

Request help with Avro IDL

I am trying to write up an IDL file so that the following avsc file will be generated by avro-tools. JSON needs to be an array of objects. I don’t know how to do this with IDL. Is it possible to achieve the following using IDL.

The avsc I am shooting for:

{
  "items": { 
    "fields": [
    {       
      "name": "name",
        "type": "string"
    },      
    {       
      "name": "age",
      "type": "int"
    }       
    ],  
    "name": "person",
    "type": "record"
  },
    "type": “array”,
   “name”: “PersonArray"
}

The JSON that works with this is:

[{“name”: “foo”, “age”: 3}]

Can this be written in an IDL? If so, please advise on what I will use top mark out the array. So far, I have the following:

protocol PersonProtocol {
  record Person {
    string name;
    int age;
  }

  record PersonArray {
    array<Person> people;
  }
}


which accepts the JSON below. Notice that I am stuck with the field name “people”. The JSON is now an object instead of an array.

{"people":[{"name”:"foo","age”:3}]

I appreciate any help with this.

Thanks
Kamesh