-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
to-evaluateIssue that has been received but not yet evaluatedIssue that has been received but not yet evaluated
Description
Is your feature request related to a problem? Please describe.
no, this is my own need and idea.
Describe the solution you'd like
such as json:
{
"name": "root",
"child": {
"name": "child"
}
}
and i want to deserialize it into the following Java object:
public class TestPojo {
private String name;
private String child;
// getter setter
}
I hope the deserialization can be successful, and the result of deserialization is:
name=root
child={"name":"child"}
Usage example
@Test
public void acceptSubJsonTest() throws Exception {
String json = "{\"name\":\"root\"," +
"\"child\":{\"name\":\"child\"}," +
"\"children\":[{\"name\":\"children\"}]," +
"\"childrenList\":[{\"name\":\"childrenList\"}]}";
ObjectMapper mapper = new ObjectMapper();
TestPojo testPojo = mapper.readValue(json, TestPojo.class);
Assertions.assertEquals(testPojo.getChild(), "{\"name\":\"child\"}");
Assertions.assertEquals(testPojo.getChildren(), "[{\"name\":\"children\"}]");
Assertions.assertEquals(testPojo.getChildrenList().get(0), "{\"name\":\"childrenList\"}");
}
Additional context
I have submitted a PR to support this issue, please click here to view.
Metadata
Metadata
Assignees
Labels
to-evaluateIssue that has been received but not yet evaluatedIssue that has been received but not yet evaluated