I've got two POJOs:
@lombok.Value
public class Foo {
String foo;
Bar bar;
}
@lombok.Value
public class Bar {
String bar;
String baz;
}
I'd like to be able to deserialize the following to a Foo
instance:
{
"foo": "some foo",
"bar": "{ \"bar\": \"some bar\", \"baz\": \"some baz\" }"
}
If I understand it correctly this the exact opposite @JsonRawValue
. There, it convert a Java String value (which is valid JSON value) to JSON object. But here, I need to convert a JSON string value to Java object.
I suspect that I need to write a custom deserializer, but I'm not sure how exactly since it involves parsing the raw JSON and assign it to the field. Maybe BeanDeserializerModifier
? (I have no idea how to use it.)
I'd like to keep the object immutable (@Value
), but I can drop this requirement if it helps solving the problem.
Thanks.