Ignore missing properties during Jackson JSON deserialization in Java

前端 未结 6 1449
时光说笑
时光说笑 2020-12-03 06:14

In the example

class Person {
   String name;
   int age;
}

If the JSON object has a missing property \'age\',

{
  name :          


        
6条回答
  •  遥遥无期
    2020-12-03 07:02

    I think you would want to use the @JsonIgnore annotation: https://fasterxml.github.io/jackson-annotations/javadoc/2.2.0/com/fasterxml/jackson/annotation/JsonIgnore.html

提交回复
热议问题