I am creating a REST API end element that adds a company to a MySQL database. The client sends a POST request with an attached data packet. A data packet is a JSON object. Suppose a JSON company object is formatted to exactly match the company class that uses the API.
How to get JSON company object data in company class? It seems silly to create an instance of the Company object, a json_decode() JSON object, and then call dozens of set() methods.
This seems to be especially stupid, since I plan to offer the same models in my client package for creating objects that are passed as JSON for my API before decoding them and mapping them to the same objects again.
Am I missing something? I constantly come across things that seem redundant when building my API, but maybe this is exactly what should happen.
T. Brian Jones
source share