Reputation: 354664
I'm comunicating with a web service via AutoBean
s 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
.
Upvotes: 4
Views: 524
Reputation: 64541
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
.
Upvotes: 5