Reputation: 103
I'm working on aria2 jsonrpc remote revoke, and I found out that all aria2 accept are strings value, like number 1 should be "1".
Although I can use JsonSerializer Annotation or use Module method, I think there should be an easy way which could apply "Int to String Serializer" to all of the fields of type int.
Could anyone give me a hint how to do this?
Upvotes: 0
Views: 1040
Reputation: 103
Finally, I found an article that has described three steps to do that, and I thought that may be a through answer:
Create a custom serializer extending the StdSerializer class
Create an object of SimpleModule class, adding to it the custom serializer and specifying for which class it must be used
Register the module on the ObjectMapper instance
ref: Jackson: create and register a custom JSON serializer with StdSerializer and SimpleModule classes
Upvotes: 1