Add JsonMapper.shared()
static method
#2176
Labels
3.x
Issues to be only tackled for Jackson 3.x, not 2.x
JsonMapper.shared()
static method
#2176
One feature that I have always resisted, offered by many other json libraries (including
jackson-jr
) is access to a global singleton instance (like gson'sGSON
). The main reason has been mutability ofObjectMapper
which has meant that it'd effectively be a stateful global singleton, prone to cause problems when one library re-configures it.But with Jackson 3.0 we finally get truly immutable mappers. Given this, there is no reason why we could not offer simple, efficient and intuitive way for "stock vanilla instance", useful for things like:
Map
s,JsonNode
sObjectWriter
, even with minor tweaks)toString()
implementation)So, let's do it.
After some thought, name
shared()
seems appropriate over alternatives considered (default()
is not possible due to Java 8 making it keyword;vanilla()
may not be intuitive;instance()
implies creation of something new).The text was updated successfully, but these errors were encountered: