AutoBeanCodex.encode leaves out properties with default values

521 views Asked by At

I'm comunicating with a web service via AutoBeans that are converted to JSON. The problem is that the web service expects every property of the JSON object to be present in the request whereas AutoBeanCodex.encode() seemingly leaves out all properties that have their default values (despite those being set explicitly).

Is there a way to include those properties too?

EDIT: Thomas' answer already helped a lot, but it still leaves a little problem. Namely an empty array (List<Integer> in my case) is swallowed as well, apparently because the default value there would be the empty array and not null.

1

There are 1 answers

3
Thomas Broyer On

A workaround would probably be to use the wrapper types instead of the primitive ones, e.g. Boolean instead of boolean, Integer instead of int; that way, the default value would be null rather than false or 0.