In database queries I can assign an Alias to any column I am returning. Is there a similar way to do that for API JSON returns?
My situation is that, I may be linking to 5 different API providers and one may use firstName, another uses First_Name etc. and it makes it difficult trying to display the data like that, it would be easier if there was a similar alias method like I would have on database queries.
An API response is like an object or data that is already created.
Output of a SQL query os the same.
So changing anything after the data is generated, is going to be manual work.
In case of SQL, alias works because there is a option to specify the alias, before this data is generated.
If the APIs have any such option to pass params for column alias, similar output can be expected as in SQL.
Custom module/formatter is your best option to say ‘define key alias mapping’ and covert the input JSON to get alias-ed output.