datasnap 的HTTP 調用返回JSON

datasnap 相關設置,就不細說了,直接上函數

 

uses System.JSON
function TServerMethods.Updatehello: Tjsonobject;
var
temp:tjsonobject;
begin
temp:=tjsonobject.Create;
temp.AddPair(Tjsonstring.Create('code'),tjsonstring.Create('00000')) ;
temp.AddPair(Tjsonstring.Create('error'),tjsonstring.Create('')) ;
result:=temp;

end;

  

調用時,輸入地址:

http://127.0.0.1:9001/datasnap/rest/TServerMethods/Updatehello

返回結果

{"result":[{"code":"00000","error":""}]}

  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章