0

How ObjectMapper maps JSON string fields with POJO attributes. If particular field(key) in the JSON String missing ?

Krishna Kumar Chourasiya
  • 2,030
  • 3
  • 20
  • 23
  • 1
    Are you using Jackson? I believe ObjectMapper is Jackson. – Pace Jul 23 '13 at 12:05
  • Yes, you are correct. – Krishna Kumar Chourasiya Jul 23 '13 at 12:59
  • I did some google and debug my code then found: If key is missing in JSON String objectMapper object will automatically set correponding property to null and read it with the getter method defined in POJO. If key's value is NULL then ObjectMapper read setter method correponding to the field from the POJO. Please correct me if I have wrong understanding .... – Krishna Kumar Chourasiya Jul 23 '13 at 13:00
  • The "how" depends highly on how you configure it. See [similar thread](https://stackoverflow.com/questions/11757487/how-to-tell-jackson-to-ignore-a-field-during-serialization-if-its-value-is-null). – Miko May 17 '18 at 10:18

0 Answers0