Building a Custom Jackson Deserializer
A partner recently provided a useful HTTP-based API for me at short notice.
The API returned simple JSON representations of the current state of various events they had periodically ingested from our REST APIs.
A decision they made was to use "yes"/"no" values in the response, rather than booleans e.g.
{
...
"exists": "yes",
"has_ended": "no"
...
}
I had written a Spring Social-based API client to interact with their API but wanted to deserialize their API response representation into a POJO that followed Java convention.
Jackson is a great Java library for processing JSON data format. It’s quite straightforward to use it to solve a problem like the above with a custom JsonDeserializer.