JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. Primarily this specification defines several data structures and the rules around their processing. It is transport agnostic in that the concepts can be used within the same process, over sockets, over http, or in many various message passing environments. It uses JSON (RFC 4627) as data format.
Example: client call method subtract with 2 params (42 and 23). Server sends a result of 19.
Client To Server --> {"jsonrpc": "2.0", "method": "subtract", "params": [42, 23], "id": 1}
Server To Client<-- {"jsonrpc": "2.0", "result": 19, "id": 1}
sgcWebSockets provides a built-in JSON component, but you can use your own JSON parser. Just implement following interfaces located at sgcJSON.pas:
IsgcJSON
IsgcObjectJSON
There are 3 implementations of theses interfaces
sgcJSON.pas: default JSON parser provided.
sgcJSON_System.pas: uses JSON parser provided with latest versions of delphi.
sgcJSON_XSuperObject.pas: uses JSON library written by Onur YILDIZ, you can download sources from: https://github.com/onryldz/x-superobject
To use your own JSON parser or use some of the JSON parsers provided, just call SetJSONClass in your initialization method. For example: if you want use XSuperObject JSON parser, just call:
SetJSONClass(TsgcXSOJSON)
If you don't call this method, sgcJSON will be used by default.