I don't really know your use case, but as a note, if you use Jackson I presume you are using ObjectMapper
. The ObjectMapper
is an expensive object which you should reuse as much as possible (ergo, declare it static
and final
), since it does a lot of caching behind the scene when the same object is converted lot of times.
Even better, get an ObjectWriter
and/or ObjectReader
from the ObjectMapper
, which are immutable and thread-safe (ObjectMapper is tricky if you want to change its configuration at runtime), they should improve your performance.
Final thing, but I never went that far, you could write custom serializer / deserializer, but I see complexity going noticeably up (thus, it will be more difficult to mantain).
If you are working with strings, double check you use the StringBuilder (or StringBuffer on multi-threaded use case) and logging only when necessary (if(logger.isDebugEnabled() { log.debug(...) }
), they are common pitfalls that bring performances down.