Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: How do I get JSON from my datasnap service


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0
Mark Tiede

Posts: 19
Registered: 5/17/98
How do I get JSON from my datasnap service  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 22, 2017 12:42 PM
No matter what I try, I only seem to get a return type of "text/html" from my datasnap service. The result LOOKS like json, but Fiddler says it is not. So I think that is causing troubles on the client. Instead of showing all my objects in a list, it shows "result" as a string.

I've tried just returning a list of objects of my own type, and I've tried creating actual json objects from my method. Fiddler always says it is not json. And my request says I accept "application/json".

Here is my latest code attempt

   function TServerMethods1.AapData: TJsonObject;
var
myData : TMyData;
list : TList<TMyData>;
begin
ADOConnection1.Connected := true;
ADOQuery1.Active := false;
ADOQuery1.Active := true;

list := TList<TMyData>.Create;

ADOQuery1.First;
while not ADOQuery1.eof do begin
mydata := TMyData.Create();
mydata.ID := ADOQuery1ID.Value;
mydata.DateTime := ADOQuery1DateTime.Value;
list.Add( Mydata );
ADOQuery1.Next;
end;

result := TJson.ObjectToJsonObject( list );
end;
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02