-
-
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
Add @JsonKey
annotation (similar to @JsonValue
) for customizable serialization of Map keys
#2871
Comments
Correct: Currently one has to register separate key serializer either using Having said that, I can see why it'd be really nice if
annotation. That would often mean having to add both |
It could be best to use another annotation indeed, like I just want to add that, currently, |
@JsonValue
: add @JsonKey
annotation?
Good point wrt different annotation for key/value aspect, somehow missed that (I think I had that in mind in the past). I'll have to see how |
@JsonValue
: add @JsonKey
annotation?@JsonValue
similar to values (no chaining?) -- maybe add @JsonKey
annotation
Yep, for example : while serializing a map key, if there is a |
I've started working on this. |
If we only put |
@Anusien Interesting... this gets quite tricky, wrt overlap of annotations, precedence. I think that it will be simpler and more reliable to keep Does this make sense? |
Just realized there's the original issue, #47, that gives more context. |
When serializing the key of a Map, look for a `@JsonKey` annotation. When present (taking priority over `@JsonValue`), skip the StdKey:Serializer and attempt to find a serializer for the inner type. Fixes FasterXML#2871
When serializing the key of a Map, look for a `@JsonKey` annotation. When present (taking priority over `@JsonValue`), skip the StdKey:Serializer and attempt to find a serializer for the inner type. Fixes FasterXML#2871
Adds support for `@JsonKey` annotation When serializing the key of a Map, look for a `@JsonKey` annotation. When present (taking priority over `@JsonValue`), skip the StdKey:Serializer and attempt to find a serializer for the inner type. Fixes #2871
@JsonValue
similar to values (no chaining?) -- maybe add @JsonKey
annotation@JsonKey
annotation (similar to @JsonValue
) for customizable serialization of Map keys
Describe the bug
When serializing a map key, if the key's type uses
@JsonValue
on one of its attributes, and if that attribute's type uses@JsonValue
on one of its own attributes, the second@JsonValue
is ignored, andtoString()
is used instead.Version information
2.10.0
To Reproduce
The text was updated successfully, but these errors were encountered: