I use Jackon to convert simple data classes to Map with
new ObjectMapper().convert(map, MyData.class);
// or vice versa
new ObjectMapper().convert(myData, new TypeReference<Map<String, String>>() {});
Now I have the requirement that the Map should contain the String "--" as value whenever the data object has a NULL value and I already have two methods that iterate over the Map entries and swap the values.
Is there a Jackson annotation that would call those convertes automatically?
I already tried @JsonSerialize(converter=…)
and @JsonDeserialize(converter=…)
but it did not seem to work. Would that have been the right approach or is there a better one?