Jackson @JsonRawValue for Map's value
jackson, java, json
Solution
No. You could easily create custom `JsonSerializer` to do that though.
Also, maybe rather just use one-off POJO:
public class RawHolder {
@JsonProperty("1")
public String raw;
}
public class Thing {
public String name;
public RawHolder content;
}
Problem
I have the following Java bean class with gets converted to JSON using Jackson. ``` public class Thing { public String name; @JsonRawValue public Map content = new HashMap(); } ``` `content` is a map who's values will be raw JSON from another source. For example: ``` String jsonFromElsewhere = "{ \"foo\": \"bar\" }"; Thing t = new Thing(); t.name = "test"; t.content.put("1", jsonFromElsewhere); ``` The desired generated JSON is: ``` {"name":"test","content":{"1":{ "foo": "bar" }}} ``` However using `@JsonRawValue` results in: ``` {"name":"test","content":{1={ "foo": "bar" }}} ``` What I need is a way to specify `@JsonRawValue` for only for the Map's value. Is this possible with Jackson?