[fpc-pascal] JSON Dataset in FCL-DB.

Leonardo M. Ramé martinrame at yahoo.com
Fri Dec 16 19:16:19 CET 2011


----- Original Message -----

> From: Michael Van Canneyt <michael at freepascal.org>
> To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> Cc: Lazarus mailing list <lazarus at lazarus.freepascal.org>
> Sent: Friday, December 16, 2011 2:53 PM
> Subject: Re: [fpc-pascal] JSON Dataset in FCL-DB.
> 
> 
> 
> On Fri, 16 Dec 2011, Leonardo M. Ramé wrote:
> 
>>  From: Michael Van Canneyt <michael at freepascal.org>
>>>  To: FPC mailing list <fpc-pascal at lists.freepascal.org>; Lazarus 
> mailing list <lazarus at lazarus.freepascal.org> 
>>>  Sent: Friday, December 16, 2011 1:37 PM
>>>  Subject: [fpc-pascal] JSON Dataset in FCL-DB.
>>> 
>>> 
>>>  Hello,
>>> 
>>>  I just committed a JSON dataset in fcl-db.
>>> 
>>>  This is a dataset which stores its data in JSON objects (as in fpjson) 
> in memory. The records are in a JSON array, each record can be a JSON object or 
> array.
>>>  (not mixed)
>>> 
>>>  The dataset is read-write. It can be used to create JSON data from 
> scratch: just add definitions to the fielddefs properties, and call 
> 'Open'. At the end, call SaveToStream().
>>> 
>>>  There are 2 descendents which read/write ExtJS JSON data packages 
> (Objects or Arrays) from streams but they are usable to handle any kind of JSON 
> data. Currently, the dataset does not yet support propagating changes (deltas) 
> back to a server.
>>> 
>>>  I would be glad to recieve feedback, comments.
>>> 
>>>  Michael.
>> 
>> 
>> 
>>  Does this allow executing selects against an sql database and traverse the 
> results using this JSON dataset?
> 
> Yes. I use it as follows:
> 
> Normally, Fcl-web server using the sql-db and fpwebdata sends JSON-Formatted 
> data to a browser.
> 
> I have now a lazarus-written client app which sends a HTTP request to the same 
> webserver, 
> reads the returned JSON, and then opens a dataset with the JSON as source of the 
> data.
> 
> Combined with the Ext.Direct RPC, I intend to use this for N-tier apps where the 
> client 
> can be a native app or a browser.
> 
> What is missing currently is the delta to update data on the server, but that 
> should be easily added.
> 
> Michael.


Thanks. 

Btw. I've found this dependency related error when I tried to compile.

...
PPU Loading /usr/local/lib/fpc/2.7.1/units/x86_64-linux/fcl-web/fpwebdata.ppu
Recompiling fpwebdata, checksum changed for db
Fatal: Can't find unit fpwebdata used by fpjsondataset
...

--  
Leonardo M. Ramé
http://leonardorame.blogspot.com



More information about the fpc-pascal mailing list