-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Provide comparator for TreeMap deserialisation #2162
Comments
I am not entirely sure whether a global configuration will be sufficient. I think the natural order for I personally think that this can be achieved through two means:
Are there any other means of implementation that I am missing? |
@cowtowncoder Could you have a short look into my proposed solutions. If there is a clear direction you'd want to see this go, I'd certainly be willing to contribute it! |
…ring[K]` instances Thank you, @jwgmeligmeyling for your questions in FasterXML/jackson-databind#2162
Apologies for missing update here. I can see why addition of an annotation would be the right way to go here, but I do not like the idea of adding a rather specific, single-use annotation -- ideally annotations would have much more general applicability. But at the same time, I can't think of superior alternatives. There is one alternative, however, that might work:
which is used as an extension point to allow custom construction of various handlers. Oh. And one other possibility, for annotation-based approach, would actually be to add a new property in I hope this helps. |
The same should be done for |
Note: #4773 improves handling in some ways to work around the issue here; but does not allow what is requested here. |
Issue replaces FasterXML/jackson-core#489, as the issue actually belonged here
Both
SortedMap
andTreeMap
can be deserialised, but by default use no special comparator is provided (i.e. natural order is used). This is because the default constructor is called for instantiating theTreeMa
p. Now you could write special deserializers or subclassTreeMap
and provide the comparator there, but that seems to be a pretty heavy change for something as easy as providing a constructor parameter for the value instantiator. Am I overseeing a certain way of how this can be achieved? And if not, could we consider introducing new annotations that allow users to specify which comparator to use for instantiated SortedSets, SortedMaps, etc?Based on my stackoverflow question: https://stackoverflow.com/questions/48151413/deserialize-a-sortedset-with-a-provided-comparator
Original response from @cowtowncoder
The text was updated successfully, but these errors were encountered: