The JSON object I GET from my vendor has inconsistent properties. Sometimes “state” exists and sometimes it doesn’t. I’ve posted data below. The first branch doesn’t have “state” and the other three do.
How can I handle when it doesn’t and add it to the data with an empty string, so it doesn’t break the flow when I POST to my destination?
{
"_embedded": {
"branches": [
{
"branchId": "33qIH0XRXrJua-OxMoj8dA",
"name": "abcd",
"timeZone": "Europe/Dublin",
"latitude": 53.35433160,
"longitude": -6.54643000,
"streetAddress1": "74 Crodaun Forest Park",
"streetAddress2": "Celbridge",
"city": "County Kildare",
"postalCode": "W23 WR26",
"country": "Ireland(Rep.)"
},
{
"branchId": "ZgLJBmQNHr1EsadecLyo9Q",
"name": "nDevor Systems Ltd",
"timeZone": "Europe/Dublin",
"latitude": 53.34886460,
"longitude": -6.26943790,
"streetAddress1": "Anglesea Mills",
"streetAddress2": "Anglesea Row",
"city": "Dublin",
"state": "County Dublin",
"postalCode": "D07 W5NE",
"country": "ireland"
},
{
"branchId": "7cUnzIvMb3vm-S4k6BxXTQ",
"name": "Ops Salon",
"timeZone": "UTC",
"streetAddress1": "100 Capel St",
"streetAddress2": "Dublin",
"city": "Dublin",
"state": "",
"postalCode": "",
"country": "Ireland"
},
{
"branchId": "F4bDLgtaqjhoH1xN4SY5cg",
"name": "Salon IT",
"timeZone": "UTC",
"streetAddress1": "100 Capel St",
"streetAddress2": "",
"city": "Dublin",
"state": "",
"postalCode": "",
"country": "Ireland"
}
]
},
"page": {
"size": 4,
"totalElements": 4,
"totalPages": 1,
"number": 0
}
}