We have a case where we have a rest endpoint and the response will be different depending on the application flow. The properties inside the json will differ, so the question is whether we want a response containing a json that will have different structure depending on application flow.
We basically have three options as I see it now. Either we could have two properties and one of them will always be null (customer or businessCustomer):
{
"data": {
"target": "Business",
"customer": null,
"businessCustomer": {
....
}
}
{
"data": {
"target": "Customer",
"customer": {
....
},
"businessCustomer": null,
}
Or we will have only one property where the the contents of that json object will differ (customer always populated):
{
"data": {
"target": "Customer or business",
"customer": {
....
}
}
I'm thinking it might be hard to consume the data with only one property. How would you serialize that in a smooth way in strongly typed langauges...
Which way is best? Thanks in advance!