You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently this should fail on attempt to serialize, due to ambiguity, I think.
If not that should be the first name.
And no, there is no way to change the behavior, whichever it is.
One thing that might work is to use explicit @JsonTypeName on Mammal: since it only takes one value, that should be the primary name to use.
@cowtowncoder thank you for the response.
In my case, this is a generated class, I can't change it, that's why I was thinking about some workarounds with jackson. Will try to do smth else with it then.
I'm closing this issue.
@amseager Probably you know this, but sharing it just in case.
If you manage to modify the code/class generation behavior, plz take note that there is property @JsonSubTypes.Type.names of type String[] used like below. That way you don't need to duplicate class.
Describe your Issue
Suppose I have smth like this (took it from this issue):
Suppose that it also wrapped in some other object:
Now you want to convert it to e.g. HashMap<String, Object>:
As I understood, in case of "Mammal" object, the very first name ("ZEBRA") will be selected as a key (string).
The question is about configuring jackson somehow to be able to select other values ("SHEEP" etc.). Maybe some settings are already exist for it?
The text was updated successfully, but these errors were encountered: