@JsonUnwrapped
doesn’t work for maps, only for proper POJOs with getters and setters. For maps, You should use @JsonAnyGetter
and @JsonAnySetter
(available in jackson version >= 1.6).
In your case, try this:
@JsonAnySetter
public void add(String key, String value) {
map.put(key, value);
}
@JsonAnyGetter
public Map<String,String> getMap() {
return map;
}
That way, you can also directly add properties to the map, like add('abc','xyz')
will add a new key abc
to the map with value xyz
.