0

This is my JSON reply

{
   "value":{
            "Status":1
             "Affected segments":[]
          "Message":[]
        }
     }

But this is what it can be in the future

{
"value":{
        "Status":2
                "Affected segments":[{a},{b},{c}]
            "Message":[
                {
                "Content": "suhrfuahfuhasufhalushflashlfuhasurhaus",
                "Created date": "12/2/21"
                },{
                "Content": "suhrfuahfuhasufhalushflashlfuhasurhaus",
                "Created date": "15/2/21"
                },
               ]
        }
}

as you can see in the 1st snippet of code the "status" is 1 to indicate nothing out of the ordinary whereas in the 2nd code snippet the "status" is 2 to indicate a change hence the array is filled.

How would I parse the two of them??

  • Does this answer your question? [How to convert the following JSON String to POJO](https://stackoverflow.com/questions/41499935/how-to-convert-the-following-json-string-to-pojo) – Anoop LL Feb 25 '21 at 07:38
  • 1
    Neither of these Json messages are valid. The first one is missing some commas at least. The second one is even worse. Are your sure your desired date format is d/M/yy? – Kristof Neirynck Feb 25 '21 at 07:43

1 Answers1

1

Could you just create simply entity Message which would store the 'Content' and the 'Date' ? Then you could store the messages in List<Message> and check whether this is empty or not, to validate the condition you have.

class Message {
 String content;
 LocalDate date;
}
mat
  • 126
  • 3