FasterXML / FasterXML/jackson-databind
Allow accepting a JSON substring using a string instead of throwing an exception
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 1.5k
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 28
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:
```json
{
"name": "root",
"child": {
"name": "child"
}
}
```
and i want to deserialize it into the following Java object:
```java
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
```java
@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](https://github.com/FasterXML/jackson-databind/pull/5232) to view.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.