Using version 2.12:
mapper.configOverride(Boolean.class).setFormat(JsonFormat.Value.forShape(JsonFormat.Shape.NUMBER));
This works as expected. Boxed Boolean values are serialized as 1/0. Moreover, it also works for primitive booleans.
However,
mapper.configOverride(boolean.class).setFormat(JsonFormat.Value.forShape(JsonFormat.Shape.NUMBER));
seems to do nothing, for either types.
I find this behavior quite surprising. I think it's reasonable to assume any of the following:
boolean implies Boolean symmetrically
boolean implies Boolean, but not the other way around (mirroring the current behavior)
- (1) + ability to override the format for the boxed type (to be clear, I've no use case for that)
- An error to be thrown by configOverride.