I’m using Jackson to serialize a custom class that implements Map<String, String>. But behind the scenes, it’s actually a Map<String, String[]> (this class represents HTTP request parameters), and I’d like for Jackson to serialize it as if it’s a Map<String, String[]>. I had thought that the JsonValue annotation would be perfect for this (I’d annotate a method that returns the inner Map<String, String[]>), but it Jackson seems to be ignoring it. How can I disable Map-style treatment of this class, and have it be serialized either as POJO or via the JsonValue annotation?
I’m using Jackson to serialize a custom class that implements Map<String, String> . But
Share
Your best choice is a custom serializer/deserializer, since there is no way for Jackson to know that your Map is “faking it” (i.e. its signature is wrong).
But if
@JsonValuedoes not work, that sounds like a bug.