FasterXML / FasterXML/jackson-future-ideas

set default value if null (or meet some condition) in deserialization

オープン
#39 コメント 5 件 リアクション 19 件 担当者 0 名 GitHub で見る
主要言語
言語のデータがありません
スター
21
フォーク
3
PR マージ指標
30日以内にマージされた PR はありません

説明

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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。