The first answer to your first question is yes, already exist such thing, and is named JSON-RPC, very creative name isn’t it? I’m sure you don’t see that coming , and you can find the project at http://json-rpc.org/.
- Inspired in the XML-RPC protocol.
- Request and Response are serialized in JSON.
- Data transported via HTTP.
- Very often used asynchronously, to avoid frozen applications while request are in process.
How it works?
Request. The request is a single object with the following properties:
- method. A string containing the name.
- params. An array of parameters.
- id. A request’s unique identifier.
Response. The response is a single object with the following properties:
- result. The result of the method call.
- error. An error object. If occurred.
- id. The request’s unique identifier.
In JSON code:
OK this post’s title and category are about PHP, so the question is: There is a PHP implementation of the JSON-RPC project? and the answer is yes, there are more than one, so here is the list of recomendations: