Jackson: new ObjectMapper()
createObjectNode is affected by global configurations?
Is it safe to use a new ObjectMapper
wherever it is needed?
Or is better to configure one to use in all application?
new ObjectMapper()
is thread safe to only have one as a singleton, just for createObjectNode?
1
It is possible to make use of multiple ObjectMapper instances to suit your needs. Without knowing finer details of your project, it might be difficult to decide which approach is “better” for you.
However, if you do decide to use a singleton instance for your application, do remember from the official documentation that
Mapper instances are fully thread-safe provided that ALL configuration
of the instance occurs before ANY read or write calls