I am trying to create a API on PHP ( web service ) and almost all the requests i need to do are to get a list of items and those items may have objects with thier own fields or maybe other objects, the api will be used for diferents proyects and not all need the same information so im trying to create a flexible request to get the structure i need on json or xml.
I dont know how to make the request without creating a big url or a big parsers for ea parm.
How can i send a structure on the web resquest???
Actual request/response.
Example request:
Http://myphpapi.php/getEmploees.php
Example response:
{"employees":[
{"firstName":"John", "lastName":"Doe", "Departament":"1"},
{"firstName":"Anna", "lastName":"Smith", "Departament":"2"},
{"firstName":"Peter", "lastName":"Jones", "Departament":"1"}]}
What i want to archive is:
Example request:
Http://myphpapi.php/getEmploees.php?{employess.firstName,Departament.name}
Example response:
{"employees":[
{"firstName":"John", "Departament":{"name":"D1"}},
{"firstName":"Anna", "Departament":{"name":"D2"}},
{"firstName":"Peter", "Departament":{"name":"D1"}}]}