4

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)

Neel
  • 233
  • 5
  • 18
  • 1
    Just to clarify your question, currently Jackson allows numbers for booleans, and you want an exception to be thrown instead if there is a number? – Paul Samsotha Aug 29 '18 at 05:16
  • 2
    https://stackoverflow.com/q/40244770/2587435 – Paul Samsotha Aug 29 '18 at 05:30
  • @PaulSamsotha Yes, I want an exception. Thank you for your inputs and provide me the useful link. If you have any other things, I would appreciate if you can share here. Thanks again. – Neel Aug 29 '18 at 12:36

0 Answers0