Hey Wai,
Good question. I've had that problem recently too. My solution has been to
set the missing field to a known default value in my code before I try to
serialize an object. That is, if some integer is required by the schema, I
do a check on my object.
if (myObject.value == null) {myObject.value = -1;}
But then you have to do this for all fields in the schema which aren't
optional. And that's kind of a pain. It'd be kind of nice if the writer
also used the default value from the schema for writing.
Thanks,
Gary
On Feb 19, 2014 10:42 AM, "Wai Yip Tung" <[email protected]> wrote:
> In the schema we can define a "default" value. It is used as default when
> reading. If the field is missing from the data when we write, it results in
> an error. Is there a counterpart of "default" in writing so that if the
> field is missing, the writer just fill in the default value?
>
> Wai Yip
>