I have list of objects in json form that are coming from an API. These objects have some attributes, the problem is some of the objects have missing attributes. so how to parse the data of the others attributes without error?
for example i have this one missing the attributes of paymentType
"user":{
"id": 6,
"name": "User",
"email": "",
"phone": "123",
"credit": null,
"fireBaseId": null,
"created_at": "2021-10-28T10:28:34.000000Z",
"updated_at": "2021-10-29T22:10:09.000000Z"
},
"paymentType": null,
"booking_type":{
"id": 1,
"name": "Mobile",
"price": 0,
"created_at": null,
"updated_at": null
}
but this all attributs exist:
"user":{
"id": 6,
"name": "User",
"email": "",
"phone": "",
"credit": null,
"fireBaseId": null,
"created_at": "2021-10-28T10:28:34.000000Z",
"updated_at": "2021-10-29T22:10:09.000000Z"
},
"paymentType":{
"id": 1,
"name": "Cash",
"active": 1,
"created_at": "2021-10-29T00:36:06.000000Z",
"updated_at": "2021-10-29T17:24:42.000000Z"
},
"booking_type":{
"id": 2,
"name": "Parking",
"price": 10,
"created_at": null,
"updated_at": null
}