Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JsonMapper.shared() static method #2176

Closed
cowtowncoder opened this issue Nov 7, 2018 · 0 comments
Closed

Add JsonMapper.shared() static method #2176

cowtowncoder opened this issue Nov 7, 2018 · 0 comments
Labels
3.x Issues to be only tackled for Jackson 3.x, not 2.x

Comments

@cowtowncoder
Copy link
Member

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's GSON). The main reason has been mutability of ObjectMapper 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:

  1. Reading of Maps, JsonNodes
  2. Writing of most types, without customization (or, via ObjectWriter, even with minor tweaks)
  3. Use from static and otherwise limited context (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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Issues to be only tackled for Jackson 3.x, not 2.x
Projects
None yet
Development

No branches or pull requests

1 participant