#1 Re: mORMot 1 » _Jsonfast » 2020-12-17 16:42:29

Yes, the problem comes from the client side.

RestRequest.AddBody methods removes the double escapes.

#2 Re: mORMot 1 » _Jsonfast » 2020-12-17 16:31:11

The solution to solve the problem was to double escape CTxt.Call.InBody before calling _JSonFast.

Any way, there's something that I don't understand : this assignment, Body:= _JsonFast(CTxt.Call.InBody), practically re-parses the received body.
As long as I don't intend to send the result somewhere via internet I don't need this function to make special chars processing.
Or, perhaps, I shouldn't use _jSonFast to put the body into a variant ?

#3 Re: mORMot 1 » _Jsonfast » 2020-12-17 16:04:43

I repeat : the double escape is made by the client application.

The client application request (the client side is based on a Delphi TRestClient) is :
{"ToAddress":"someaddress.gmail.com", "Attachment":"c:\\photos\\photo1.bmp"}

But on the server side  CTxt.Call.InBody is  {"ToAddress":"someaddress.gmail.com", "Attachment":"c:\photos\photo1.bmp"}

#4 Re: mORMot 1 » _Jsonfast » 2020-12-17 14:38:24

Thank you for your reply.

I'm not sure I got understood.

Of course, double escape is made by the client application, otherwise the rest server wouldn't get the correct information.

Or, may be, do you suggest to double escape the received CTxt.Call.InBody   before calling _JsonFast ?

#5 mORMot 1 » _Jsonfast » 2020-12-17 13:09:02

gseica
Replies: 9

Hello,
can any one tell me what's wrong with the code bellow :

TRestServer = class(TSQLRestServerFullMemory)
  protected
...
  public
    constructor Create(const aRootFolder: TFileName; const aRootURI: RawUTF8); reintroduce;
    destructor Destroy; override;
    property RootFolder: TFileName read fRootFolder;
  published
....
    procedure SendMail(Ctxt: TSQLRestServerURIContext);
  end;

...

procedure TRestServer.SendMail(Ctxt: TSQLRestServerURIContext);
var
  Body      : variant;
begin
  // the client's application request body looks like this
// {"ToAddress":"someaddress.gmail.com", "Attachment":"c:\photos\photo1.bmp"}

// the debuger shows  that CTxt.Call.InBody contains the same information that the client application sends
  Body:= _JsonFast(CTxt.Call.InBody);
// after calling _JSonFast I find that Body.Attachment is 'c:photosphoto1.bmp
end;

Can you tell me how I can avoid this ?

#6 Re: mORMot 1 » DataSnap Rest Server to mORMot » 2019-08-15 14:04:34

Hi,

The most of the DataSnap functions in our project look like these :

function DoSomething1(DataIn : TJSonValue) : TJSonObject;

or

function GetSomething(DataIn : TJSonValue) : TJSonArray;


We can't figure how we can return a json array from a mORMot method.

#7 Re: mORMot 1 » DataSnap Rest Server to mORMot » 2019-08-13 09:23:25

Thank you for your quick reply.

Best regards.

#8 mORMot 1 » DataSnap Rest Server to mORMot » 2019-08-12 11:22:26

gseica
Replies: 4

During the last 4 years we have developed a DataSnap Rest Server application that allows other applications to send documents (invoices, orders, account statements, etc) into our Oracle ERP application, or to query 

data from our database.

Due to the well known DataSnap's stability problems, we are thinking about migrating this project to mORMot.

There are a few facts that we have to care about before taking a decision :

- The project is very big and we don't have enough time to rewrite it from zero

- There are tens of other client applications that are using now our DataSnap solution so, we have to keep the same JSon structures for exchanging data


Most of the DataSnap get... methods have JSon parameters  that allow the client applications to define different filtering criteria.

The returned Json data is based on queries  or/and Oracle stored procedures (some of the interrogations need some complex algorithms)


The update.. methods have Json parameters that describe the documents (invoices for instance).
If the received data is valid, the document is saved into the database together with some accounting registrations.


We studied some of mORmot's sample projects and it seems that mORMot's terminology is completely different from the DataSnap's terminology.


Our question is : can any one share his experience in migrating from DataSnap Rest to mORMot and give us some hints ?



Thank you

Board footer

Powered by FluxBB