Jackson JSON Provides Boolean Type Serialization and Deserialization

I have a problem using Boolean wrapper with JSON Object, when a JSON object is created for boolean values, it contains cotes strings, for example "isUrgent" : "1"Now the problem is that I have to wrap it manually each time in my code for each request / response

Can any body provide me with a permanent solution to the above problem?

+3
source share
2 answers

The solution is to configure the deserializer for the boolean type. All you have to do is add an extra deserializer that could handle the case of specific String values ​​that you are trying to deserialize as Boolean.

.

http://hussainpithawala.wordpress.com/2011/05/11/overriding-default-serializationdeserialization-behaviour-of-jackson-json-serializer/

+3

, JSON ( );

  • null
  • String ("") false
  • "true" "false"
  • 0 ; true

, .

+2

All Articles