#1 2015-03-04 17:12:16

automacaosamos
Member
Registered: 2015-02-19
Posts: 20

Convert JSONtoDataSet Sample

I would like to fill a DataSet with a JSON
I'm trying like this but I'm not getting it.
someone help me?

  TB_MANAGER := TDataSet.Create(nil);
  TB_MANAGER := JSONToDataSet(self, '{"ID":"00001","NAME":"MANAGER E CIA LTDA"}');
  TB_MANAGER.Open;

  DS_MANAGER                   := TDataSource.Create(nil);
  DS_MANAGER.DataSet       := TB_MANAGER;
  DBGridManager.DataSource := DS_MANAGER;

thanks !!

Offline

#2 2015-03-04 18:02:50

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Convert JSONtoDataSet Sample

1. your first TB_MANAGER := TDataSet.Create(nil) will leak memory since you are re-assigning TB_MANAGER := JSONToDataSet()

2. Open is not mandatory AFAIR

3. See sample https://github.com/synopse/mORMot/blob/ … CLUnit.pas

4. See duplicate of your own post at http://synopse.info/forum/viewtopic.php … 098#p15098

Offline

Board footer

Powered by FluxBB