I have  a JSON String (sample ) as follows and I created a Mapper POJO using Jackson to handle the same but as I saw the data I noticed the mentioned issue

How do I handle the below change in data from String to String [] in my POJO mapper class any ideas would be helpful

 

<code>

@JsonIgnoreProperties(ignoreUnknown = true)
public class Ref implements Serializable {

@JsonProperty("BBT")
  private String BBT;

.... more code here



//Sample 1
"Ref": {
      "ISN": "AEBDC44",
      "CCD": "213128908338",
      "BGID": "XCAS3213213",
      "BBS": "23123123",
      "BBT": "CCC",
      "WRT": "POP91230",
      "SDL": "290123",
      "BUN": "ZZRET10PV4",
      "BCSP": "ZZRET10PV4",
      "CSP": "ZZRET10PV4"
    }

//Sample 2
"Ref": {
      "ISN": "AEBDC44",
      "CCD": "213128908338",
      "BGID": "XCAS3213213",
      "BBS": "23123123",
      "BBT": ["CCC","AAA"],         //Sometimes recevied as an String array instead of String
      "WRT": "POP91230",
      "SDL": "290123",
      "BUN": "ZZRET10PV4",
      "BCSP": "ZZRET10PV4",
      "CSP": "ZZRET10PV4"
    }

</code>

FacebookTwitterLinkedin
Pin It
Joomla Tutorials for Beginners