I have the following class that I deserialize incoming JSON:
data class Foo(
val result: List<Map<String, Any>>,
)
I want to filter out specific keys from it.
For instance, if Map contains the key foo, I want to remove it.
I know that there are @JsonIgnore and @JsonIgnoreProperties annotations, but I don't think that they're useful on a Map.
Currently, I filter the map, but I wonder if there is a more Jackson-specific way to do this (e.g. using filters).
You can still add the annotations using mixins - more specifically ObjectMapper.addMixin(target, mixinSource).
Let's say this is your mixin:
All annotations on
MapMixinwill be added toMaps using the method above:The above example will serialize the map as: