I'm using Jackson library for serialization. To indent the output I have the following code
ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
This results in adding spaces that I don't need. For example,
{
"id" : 2,
"name" : "theUser"
}
I want my output to be
{
"id": 2,
"name": "theUser"
}
Basically, I want space between key and : to be removed. Is there a easy way to get rid of this additional space?
Although Ivar provided the answer already in his comment, here's my implementation of it, which returns your desired result.
where MyPrettyPrinter is the following:
}