I have the following Java bean class that converts to JSON using Jackson.
public class Thing {
public String name;
@JsonRawValue
public Map content = new HashMap();
}
contentis a map whose values will be raw JSON from another source. For instance:
String jsonFromElsewhere = "{ \"foo\": \"bar\" }";
Thing t = new Thing();
t.name = "test";
t.content.put("1", jsonFromElsewhere);
Desired generated JSON:
{"name":"test","content":{"1":{ "foo": "bar" }}}
However, use @JsonRawValueresults in:
{"name":"test","content":{1={ "foo": "bar" }}}
I need a way to specify @JsonRawValueonly for the value of the map. Is this possible with Jackson?
source
share