JSON to objects and grid

<< Click to Display Table of Contents >>

Navigation:  Examples >

JSON to objects and grid

Parse customers.json file, create list of TCustomer from this JSON, display list in grid.

 

type
  TCustomer = class
  public
    CustomerID: integer;
    Active: boolean;
    Name, Address, City, Country, Email: string;
    function OnSubscription(ADate: TDateTime): boolean;
  end;

  TCustList = TObjectList<TCustomer>;
 ...
  CL := TCustList.Create;
  Res := THtSQL.FromFolder(SelectedFolder, 'select * from customers', []).Unserialize(
    function: TObject begin 
      Result := TCustomer.Create; 
      CL.Add(TCustomer(Result)) 
    end);
 
  THtSQL.FromObject(CL, 'select name, address, OnSubscription(CURRENT_DATE) from data order by name', []).ToDataset(FDMemTable1);