#1 2013-03-30 08:30:10

wai-kit
Member
From: Amsterdam, the Netherlands
Registered: 2012-11-27
Posts: 90

Building JSON client with mORMot. Possible?

Hi everyone,

I want to create a client that can consume webservices other than those created with the mORMot framwework. These
webservices communicates through JSON.

Is this possible and what steps do I need to take?

Thanks,
Wai


fpcdeluxe, FPC 3.2 / Lazarus 2.0, mORMot on Windows 10 ...

Offline

#2 2013-03-30 09:39:34

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

Re: Building JSON client with mORMot. Possible?

You have all needed bricks at hand, i.e. HTTP requests and JSON parsing.

But the JSON parsing is optimized for the mORMot layout.
http://blog.synopse.info/post/2011/06/0 … ON-parsing
In short, this is a SAX in-place parser, optimized for the mORMot requests.
It won't create a DOM tree, as other parsers do.

Do you need a DOM access, i.e. direct access to any node.
We may easily add it over the SAX parser.
I suppose we may be able to make something very fast, not based of one class instance per node, but with record and arrays structures - with the same DOM syntax on your side.

Online

#3 2013-03-31 08:58:50

wai-kit
Member
From: Amsterdam, the Netherlands
Registered: 2012-11-27
Posts: 90

Re: Building JSON client with mORMot. Possible?

To connect a HTTP client I need to pass a TSQLModel as one of the arguments:

   client := TSQLHTTPClient.create(ServerAddres, ServerPort, Model)

Can I simply pass nil as Model?

As for JSON, I will be using the JSONtoDataset routines.


fpcdeluxe, FPC 3.2 / Lazarus 2.0, mORMot on Windows 10 ...

Offline

#4 2013-03-31 11:41:19

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

Re: Building JSON client with mORMot. Possible?

The TSQLRest children (like TSQLHTTPClient) are ORM and MVC oriented.
So it NEEDS a TSQLModel, by design.

It won't help you for client side, since it has its own REST routing scheme, based on the ORM model.

See http://synopse.info/fossil/finfo?name=S … Server.dpr
and http://synopse.info/fossil/finfo?name=S … Client.dpr
for some code by-passing the mORMot ORM kernel and REST routing.

Online

#5 2013-03-31 17:25:36

wai-kit
Member
From: Amsterdam, the Netherlands
Registered: 2012-11-27
Posts: 90

Re: Building JSON client with mORMot. Possible?

Merci beaucoup for the tip. This one has put me on route again smile.


fpcdeluxe, FPC 3.2 / Lazarus 2.0, mORMot on Windows 10 ...

Offline

Board footer

Powered by FluxBB