json to data

hi, i wount standdard join data display on the website. how i can do this ?


Sampledata

https://jsonplaceholder.typicode.com/users


You can bind it to a TWebDataSource by adding a TWebConnection and set WebConnection.URI = https://jsonplaceholder.typicode.com/users

Then you could display the data in TMSFNCGrid via a TMSFNCDataGridAdapter or you could loop through the dataset and add the desired data to any web list control

Sorry, i don't konw how it works ?


WebClientConnection1 with uri https://jsonplaceholder.typicode.com/users

WebClientDataSet1 with connected to WebClientConnection1

WebDataSource1 with DataSet :WebClientDataSet1

TMSFNCGridDatabaseAdapter1 : - DataSet ->WebDataSource1 Grid ->TMSFNCGrid1

procedure TForm1.WebButton1Click(Sender: TObject);
begin
 WebClientConnection1.Active:=True;
 TMSFNCGridDatabaseAdapter1.Active:=True;
end;




Did you add fields to the dataset (can be done automatically at design-time from the dataset context menu: Fetch fields and then add all fields that were fetched.

i dont 't know how i can start. i have looked your dataset sample, this are no real live data ...

my openinge dataset:

  WebClientConnection1.DataNode := '';
  WebClientDataSet1.FieldDefs.Clear;
  WebClientDataSet1.FieldDefs.Add('id',ftInteger,0);
  WebClientDataSet1.FieldDefs.Add('name',ftstring,50);
  WebClientDataSet1.FieldDefs.Add('username',ftstring,50);
  WebClientDataSet1.FieldDefs.Add('email',ftstring,50);

  WebClientConnection1.Active := true;

  WebClientDataSet1.Active:=True;
  TMSFNCGridDatabaseAdapter1.Active:=True;

The code to open the dataset looks good. If you execute this code, what exactly is happening, what exactly do you see go wrong (if there is an error)?

if i look between your logig and "normal json" i need the optunity to add the row artibute:


no errors: 


Webclientdataset.Recordcount=0

Is the json data properly structured, i.e. as json array or array organized under a datanode?Bruno Fierens2018-05-28 21:41:01

hear are jsontestdatas, i wont display this datas:


https://jsonplaceholder.typicode.com/photos


I cannot see an issue. I put a sample together. You can download it here:

http://www.tmssoftware.net/public/datasetsample.zip

i have tested thias sample an it works ....


the different ist the DataNode property

WebClientConnection1.DataNode := '';


There is no datanode in the json, so it should be set to empty.

heare my code


procedure TForm1.WebButton1Click(Sender: TObject);
begin
  TMSFNCGridDatabaseAdapter1.Active:=False;;
  WebClientConnection1.Active := False;

  WebClientConnection1.URI := 'https://jsonplaceholder.typicode.com/photos';
  WebClientConnection1.DataNode := '';
  WebClientDataSet1.FieldDefs.Clear;
  WebClientDataSet1.FieldDefs.Add('albumId',ftInteger,0);
  WebClientDataSet1.FieldDefs.Add('id',ftInteger,0);
  WebClientDataSet1.FieldDefs.Add('title',ftstring,250);
  WebClientDataSet1.FieldDefs.Add('url',ftstring,250);
  WebClientDataSet1.FieldDefs.Add('thumbnailUrl',ftString,255);
  WebClientConnection1.Active := true;
end;

procedure TForm1.WebDataSource1StateChange(Sender: TObject);
begin
 if WebClientDataSet1.State=dsBrowse then begin
  WebButton1.Caption:=IntToStr(WebClientDataSet1.RecordCount);
  TMSFNCGridDatabaseAdapter1.Active:=True;
 end;
end;

Please work with the dataset only from the connection.OnAfterConnect event.

Test code returns 5000 records here:


uses
  Weblib.webtools;

procedure TForm2.WebButton1Click(Sender: TObject);
begin
  WebClientConnection1.Active := False;

  WebClientConnection1.URI := 'https://jsonplaceholder.typicode.com/photos';
  WebClientConnection1.DataNode := '';
  WebClientDataSet1.FieldDefs.Clear;
  WebClientDataSet1.FieldDefs.Add('albumId',ftInteger,0);
  WebClientDataSet1.FieldDefs.Add('id',ftInteger,0);
  WebClientDataSet1.FieldDefs.Add('title',ftstring,250);
  WebClientDataSet1.FieldDefs.Add('url',ftstring,250);
  WebClientDataSet1.FieldDefs.Add('thumbnailUrl',ftString,255);
  WebClientConnection1.Active := true;

end;

procedure TForm2.WebClientConnection1AfterConnect(Sender: TObject);
begin
  outputdebugstring(inttostr(webclientdataset1.RecordCount));
end;
I'am sorry, in my version it don't works : 
Version 0.9.6.0 (Tuesday, May 22, 2018)

in onafterconnect it appears a error,  in a serperate button it appears 0 Recordcount:


implementation

uses
  Weblib.webtools;

{$R *.dfm}

procedure TForm4.WebButton1Click(Sender: TObject);
begin
  WebClientConnection1.Active := False;

  WebClientConnection1.URI := 'https://jsonplaceholder.typicode.com/photos';
  WebClientConnection1.DataNode := '';
  WebClientDataSet1.FieldDefs.Clear;
  WebClientDataSet1.FieldDefs.Add('albumId',ftInteger,0);
  WebClientDataSet1.FieldDefs.Add('id',ftInteger,0);
  WebClientDataSet1.FieldDefs.Add('title',ftstring,250);
  WebClientDataSet1.FieldDefs.Add('url',ftstring,250);
  WebClientDataSet1.FieldDefs.Add('thumbnailUrl',ftString,255);
  WebClientConnection1.Active := true;

end;

procedure TForm4.WebButton2Click(Sender: TObject);
begin
 weblabel1.caption:=inttostr(webclientdataset1.RecordCount);
end;

procedure TForm4.WebClientConnection1AfterConnect(Sender: TObject);
begin
 ShowMessage('geladen');
end;

Hi, i have installed 0.9.6.0; delphi (Berlin) show in the splash screnn 0.9.4 ?

now it's works!


Hear ist a setup problem.

i have manually deleted the old version from webcore and have new installed !

Thanks for informing!