-
-
Notifications
You must be signed in to change notification settings - Fork 143
Create SmileMapper based on a existing ObjectMapper? #205
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
Comments
As of 2.x, neither is possible, although you can replace But it is an interesting use case still, since much/most of Which settings are you specifically interested in keeping? I'd like to understand usage to think of whether and how support could be added. |
My use case is around Hazelcast usage: I have my primary ObjectMapper that is used for regular JSON with HTTP requests, etc. All of the de/serializers, preferences, etc are the same in both. It is just that Hazelcast requires the binary format. |
@cowtowncoder the |
@StephenOTT For this particular setting I would probably try to keep references to |
@cowtowncoder after some further investigation into the use case, I have found that The higher level scenario here is you have your JSON mapper for typical json usage (APIs, etc). you end up with a DI circular dependency because the de/serializers may have DI in them. So it would seem a more powerful such as
Where copy configuration is some wrapper class that holds all of the refs that are in the ObjectMapper copy constructor The goal being to provide some more granular copy controls to prevent certain parts from copying over (such as certain modules, replacement of JsonFactory, etc) (it could even be to remove all modules, and you have to explicitly define the re-import). |
While I can see added power from lambda-style approach (can't be real lambda since Jackson 2.x is still Pre-java8 minimum, but functional interface would do fine), it also sounds like bit of a potential rat hole just wrt complexity (of figuring out API to use). It is too bad that 3.0 is so far out (and moves things in bit different direction), since it will cleanly separate configuration behind builders, and sort of solves the problem with module registration you refer to: in 2.x, module registration simply causes configuration changes and there is no way to separate such settings from any other changes. 3.0 changes this completely so that there is a full copy of configuration settings Builder has, including Modules to add -- and although But back to 2.x and specific problem: the only really immutable aspect of Since registration effects of modules can not really be undone, I guess the main alternative addition could be to have some sort of "partial copy" that would only copy some subset of settings, like So I don't know of clean solution. But it could perhaps help to know sort of prioritized list/set of configuration settings that would be most valuable to retain? |
This seems to be possible now with the |
Good point @pfyod. Should work for Smile mapper at least. Closing. |
is it possible to replace a JsonFactory in a copy of a ObjectMapper, or configure the SmileMapper to use all of the configs of a existing ObjectMapper?
The text was updated successfully, but these errors were encountered: