Add support for handling `Map.Entry`
See original GitHub issueSince use of Map.Entry
as type is relatively common for constructs like Iterable<Map.Entry<>>
or List<Map.Entry<>>
, it’d make sense to support it.
By default, serialization should probably occur as JSON Object with just one entry. Deserializer will need to do bit of verification after entry, to give more meaningful error for possible case of structural mismatch.
A potential added twist is whether to try to optimize more compact forms: specifically, Iterable
(or Iterator
) of Map.Entry
instances could conceivably be simply serialized as JSON Object, instead of JSON Array of single-entry JSON Objects.
One possibility would be to initially support deserialization of such structure (as it should be detectable from JSON Array vs JSON Object difference); and later on maybe add support for serialization as well, using @JsonFormat
to indicate difference.
Issue Analytics
- State:
- Created 9 years ago
- Comments:15 (8 by maintainers)
Top GitHub Comments
@pedro93 You can use:
annotation on property, to serialize “as POJO” (i.e. with 2 fields); and:
to serialize using new compact notation.
And to set this as the default, you should be able to use:
as “per-type config override”.
@cowtowncoder
Sorry to pile on here. We’re looking to control the wire format of our custom Map.Entry class. I’ve set:
Per your instructions, but it doesn’t seem to work.
We can’t, or rather would like to avoid annotating the custom Map.Entry implementation to maintain separate between the serialization layer and the object layer as we have several different serializers.
We also can’t reference the concrete type from the serialization module.
Using Jackson 2.9.1.
Any thoughts?