#1 2020-03-29 22:09:09

Hafedh TRIMECHE
Member
Registered: 2016-09-18
Posts: 37

Convert Data to Json failed [TypeInfo]

https://github.com/synopse/mORMot

SVN Version: 8975
-------------------------------
This structure used to generate Json by invoking the function _J_.Encode.
The function failed giving the file linked TCPAuth.Json.

  TTCPAuthentication =
  packed record
    HostUniqueID       : string;
    ApplicationName    : string;
    ApplicationVersion : Extended;
    LicenseRequired    : Boolean;
    JsonLicense        : string;
    LicenseRequested   : Boolean;
    Cert               : string;
    SessionID          : Int64;
    Challenge          : string;
    Signature          : TBytes;
    CompressAlgo       : string;
    UserProfile        : Byte;
    function  Marshal:TBytes;
    procedure Unmarshal(Bytes:TBytes);
  end;

class function _J_.Encode<T>(Data:T):string;
var
  RttiInfo : Pointer;
begin
  try
    RttiInfo := TypeInfo(T);
    TTextWriter.RegisterCustomJSONSerializerSetOptions(RttiInfo,[soWriteIgnoreDefault],True);
    Result := string(RecordSaveJSON(Data,RttiInfo,True));
  except
    Result := '';
  end;
end;

SVN Version: 8777
-------------------------------
Please note that Json conversion worked well with this version.

Best regards.

Offline

#2 2020-03-30 12:32:09

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

Re: Convert Data to Json failed [TypeInfo]

Please retry with latest version.

I guess https://github.com/synopse/mORMot/commi … b364a5af9a may fix the problem (if you are using a Delphi Unicode revision).

Offline

#3 2020-04-01 11:15:03

Hafedh TRIMECHE
Member
Registered: 2016-09-18
Posts: 37

Re: Convert Data to Json failed [TypeInfo]

Thank you.

It worked well with revision: 8984

Best regards.

Offline

Board footer

Powered by FluxBB