In JSON boolean type allow to pass int, instead of throwing error

Viewed 686

Here,

isChecked and isPrime both are the boolean type. If I am passing integer to both value, in my java code instead of throwing exception/error (code should expect either 'true' or 'false'), it is mapping with true value in my POJO class. I am assuming that it because of any number greater than 0 will take boolean true. To avoid this thing, any suggestions? I am using jax-rs for deserializing and serialize to java object.

@JsonProperty
private boolean isChecked;

(In setter method, it set with true value)

0 Answers
Related