On Wed, Feb 27, 2013 at 11:21 PM, Pankaj Shroff <[email protected]> wrote: > Yes thats right, and the default value can be "null" - which is what makes > "b" an "optional" field. > > You can define an optional field by defining it of type "union" in an Avro > schema where the first type in the union is "null" and the second type is > "long" or integer in your case. > > Something like this (.avsc or .avpr file would have the following Json): > > > { > "type": "record", > "name": "OptionalFieldsExample", > "fields": [ > {"name": "a", "type": "long"}, > {"name": "b", "type": ["null", "long"]}, > {"name": "c", "type": ["null", "long"]} > > > ] > } >
Is that a reader's or a writer's schema? Sorry for the newbie questions... -- Francis Galiegue, [email protected] JSON Schema in Java: http://json-schema-validator.herokuapp.com
