#51 Re: mORMot 1 » Class to JSON » 2014-02-12 23:43:06

Wonder. Thanks for the tips. See how it fits:

type
  TInsReg = packed record
    fIdent   : RawUTF8;
    fIdSetup : RawUTF8;
    fObs     : TSQLRawBlob;
    fPriority: Integer;
    fRefCond : RawUTF8;
    fRefVal  : RawUTF8;
    fIndex   : array of record
       fField: RawUTF8;
       fCond : RawUTF8;
       fVal  : TSQLRawBlob;
    end;
  end;

const
   __TInsReg = 'fIdent RawUTF8 fIdSetup RawUTF8 fObs RawUTF8 fPriority Integer fRefCond RawUTF8 fRefVal RawUTF8 fIndex[fField RawUTF8 fCond RawUTF8 fVal RawUTF8]';

   TTextWriter.RegisterCustomJSONSerializerFromText(TypeInfo(TInsReg),__TInsReg);

..............

It worked perfectly. My last question in this context. How do I define the TSQLRawBlob const __ TInsReg?

When I set so I get an error that is TSQLRawBlob not recognized.

   __TInsReg = 'fIdent RawUTF8 fIdSetup RawUTF8 fObs TSQLRawBlob fPriority Integer fRefCond RawUTF8 fRefVal TSQLRawBlob fIndex[fField RawUTF8 fCond RawUTF8 fVal TSQLRawBlob]';

#52 Re: mORMot 1 » Class to JSON » 2014-02-12 10:09:51

ok.
I am developing a webservice (dll).

I changed my code:

TIndex= class(TPersistent)
  private
    fField:string;
    fCond:string;
    fVal:WideString;
  published
    property AField:string read fField  write fField; //Nome do campo
    property ACond:string read fCond write fCond;     //Condicao
    property AVal:WideString read fVal write fVal;    //Valor(es)
  end;

  TIndexStructure = array of TIndex;

  TInsReg = class(TPersistent)
  private
    fIdent   : RawUTF8;
    fIdSetup : RawUTF8;
    fObs     : TSQLRawBlob;
    fPriority: Integer;
    fRefCond : RawUTF8;
    fRefVal  : RawUTF8;
    FIndex   : TIndexStructure;
  published
    property AIdent   : RawUTF8 read fIdent write fIdent;
    property AIdSetup : RawUTF8 read fIdSetup write fIdSetup;
    property AObs     : TSQLRawBlob read fObs write fObs;
    property APriority: Integer read fPriority write fPriority;
    property ARefCond : RawUTF8 read fRefCond write fRefCond;
    property ARefVal  : RawUTF8 read fRefVal write fRefVal;
    property AIndex   : TIndexStructure read FIndex write FIndex;
  end;

------

I need to send (client side) and receive (webservice side) class TInsReg.

I thought about doing this with the function call:
fn_InsReq function (AInsRegSend: RawJSON): RawUTF8;

-------------------

I already do it by delphi but I'm wanting to use mormot.

In your opinion, how should I proceed for this?

How should I serialize (JSON), the client side, and to send and receive in webservice side and unserialize?

Thanks foe your hep.

#53 mORMot 1 » Class to JSON » 2014-02-11 11:15:14

Celso
Replies: 7

I have my class :

TIndex = class ( TRemotable )
  private
    fField : string ;
    fCond : string ;
    FVal : WideString ;
  published
    property Afield : String read write fField fField / / Field Name
    ACOND property : String read write fCond fCond / / Condition
    Aval property : WideString read FVal FVal write / / Value (s )
  end ;

  TIndexStructure = array of TIndex ;

.....

code to initialize :

var
   v_index : TIndexStructure ;
   v_count : Integer;
begin
   try
      SetLength ( v_index , cdsIndex.RecordCount ) ;
      cdsIndex.First ;
      v_count : = 0;
      while not the cdsIndex.Eof
      begin
         v_index [ v_count ] : = tIndex.Create ;
         . v_index [ v_count ] Afield : cdsIndex.FieldByName = ( ' AINDEX ' ) Value; .
         . v_index [ v_count ] ACOND : cdsIndex.FieldByName = ( ' ACOND ' ) AsString ; [1] .
         . v_index [ v_count ] Surety : cdsIndex.FieldByName = ( ' AVAL ' ) Value; .
         Inc ( v_count , 1);
         cdsIndex.Next ;
      end ;
   except
   ...
   end ;
end ;

question :
HOW DO I TURN THIS IN CLASS JSON ?

#54 Re: mORMot 1 » Examples » 2013-05-14 16:25:43

Thanks for the feedback.
I think I'm doing something wrong. I can not open the sub-folder of the examples. Can help me with this?

#55 mORMot 1 » Examples » 2013-05-14 15:09:03

Celso
Replies: 3

Gentlemen, good morning
I have used the DataSnap, Delphi, as the application server. But I have faced many problems.
I'm trying to use the mormot, but I'm serious difficulties and doubts. Could you tell me if there is a simple example, as a customer base, using any database. So I can see how best to use the tools.

Board footer

Powered by FluxBB