Advertisement
danieleteti

DMVCFramework :: Renders JSON array vs JSON object

Apr 30th, 2024
1,267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.73 KB | Source Code | 0 0
  1. // This action renders an array of json objects
  2. procedure TCustomersController.GetCustomers([MVCFromQueryString('rql','')] RQLFilter: String);
  3. begin
  4.   if RQLFilter.IsEmpty then
  5.     Render<TCustomer>(TMVCActiveRecord.All<TCustomer>)
  6.   else
  7.     Render<TCustomer>(TMVCActiveRecord.SelectRQL<TCustomer>(RQLFilter, 1000));
  8. end;
  9.  
  10. // This action renders a jsonobject containing a property "data" which contains an array of json objects
  11. procedure TCustomersController.GetCustomers([MVCFromQueryString('rql','')] RQLFilter: String);
  12. begin
  13.   if RQLFilter.IsEmpty then
  14.     Render(ObjectDict().Add('data', TMVCActiveRecord.All<TCustomer>))
  15.   else
  16.     Render(ObjectDict().Add('data', TMVCActiveRecord.SelectRQL<TCustomer>(RQLFilter, 1000)));
  17. end;
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement