FasterXML / FasterXML/jackson-future-ideas
set default value if null (or meet some condition) in deserialization
- Dominant language
- No language data
- Stars
- 21
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
I'm wondering if we can have an annotation (field level and class level) to set a default value if the corresponding JSON value is null in deserialization.
```json
{
"name": "Jack"
}
````
```java
class People {
String name;
@JsonDefault(intDefault = 10)
Integer age;
}
```
After deserialization, We can have people.name == "Jack" and people.age == 10.
```java
@JsonDefault(floatDefault = 0.0f, intDefault = 0)
class People {
String name;
Integer age;
Float weight;
}
```
After deserialization, We can have people.name == "Jack", people.age == 0 and people.weight == 0.0
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.