//------------------------------------------------------------------------------ // Uint: 例子/JSON处理者 //------------------------------------------------------------------------------ unit jsonhandler; interface uses System.SysUtils, System.IOUtils, System.Classes, FireHttp.Utils, FireHttp.Types, FireHttp.Classes, FireHttp.JSON, FireHttp.Path, FireHttp.Log, FireHttp.Config; type example_jsonhandler = class(TJSONHandler) private const __PathInfo = '/jsonhandler'; const __Description = ''; protected procedure Execute; override; procedure Cleanup; override; public constructor Create(AThread: TWorkerThread); override; destructor Destroy; override; end; implementation { example_jsonhandler } procedure example_jsonhandler.Cleanup; begin inherited; end; constructor example_jsonhandler.Create(AThread: TWorkerThread); begin inherited Create(AThread); {$region '设置处理者'} MultiPathInfo.Add(__PathInfo); Description := __Description; {$endregion} end; destructor example_jsonhandler.Destroy; begin inherited; end; procedure example_jsonhandler.Execute; begin inherited; with Document.Root do begin AddNode('errorcode', 0); AddNode('userid', 1); AddNode('username', 'user1'); AddNode('password', '123456'); end; end; initialization RegisterHandlerClass(example_jsonhandler); end.