I have a Java map Map<String, String> map = Collections.singletonMap("dummyKey", "dummyValue")
.
When I use ObjectMapper to serialize it, I get {"dummyKey":"dummyValue"}
.
Is there any way that I can insert JSON keys in the process of serialization so my JSON string looks like {"key":"dummyKey", "value":"dummyValue"}
.
I'd like to be able to do this without having to create a separate class, if possible. I'm looking for something like the allow explicit property renaming feature.
I looked at the other mapper features provided, but can't find anything useful. I don't want to create a different class because I want to retain the ability to be able to use it as a map (look up by key) when I deserialize it later. I'm looking for something that'll only change the way serialization and deserialization happen.