#1 Re: mORMot 2 » How to converting JSON to class » 2024-03-07 02:06:31

  TCompanyData = packed record
    Actived: integer;
    Address: string;
    CompanyName: string;
    Domain: string;
    EmployeeName: string;
    LogoUuId: string;
    TenantAccountId: integer;
    TenantId: integer;
    TenantType: integer;
    WxwCorpId: string;
    WxwRealCorpId: string;
  end; 

var
rd:TCompanyData;
Mjstr:string;
begin

MjStr:='{"actived":0,"address":"Dh,"companyName":"dhxxx",'+
  '"domain":"jyj","employeeName":"loadymf","logoUuid":"0080g974ae783d153214514",'+
  '"tenantAccountId":4864,"tenantId":1079,"tenantType":4,"wxwCorpId":"wpbY5x"'+
  ',"wxwRealCorpId":"ww64df1a47"}

   mormot.core.json.RecordLoadJson(rd,pointer(MjStr),typeinfo(rd));
  ShowMessage(rd.CompanyName);//disp null  ,I found ,rd load nothing;

#2 mORMot 2 » How to converting JSON to class » 2024-03-07 02:00:53

loadymf
Replies: 2

I have a program that returns JSON data after a login request.(I use laz 2.2.4 fpc 3.2.2 mormot2)
Successful login returns JSON data,Other responses in the "datas" field will return multiple pieces of data

{"status":"200","flag":"SUCCESS","message":"操作成功",' "action":"safetyLogin","version":"v1.0","format":"json","datas": [{"sessionUuid":"0cdb276a98a24d03aad4814e9d059781","tenantCountFlag":2}]}

Login failure returns JSON data

{"action":"safetyLogin","version":"v1.0","format":"json","status":"500",' +
    '"flag":"NOT_FOUND","message":"帐号尚未注册"}

an other respone datas data :
{"actived":0,"address":"Dh,"companyName":"dhxxx",'+
  '"domain":"jyj","employeeName":"loadymf","logoUuid":"0080g974ae783d153214514",'+
  '"tenantAccountId":4864,"tenantId":1079,"tenantType":4,"wxwCorpId":"wpbY5x"'+
  ',"wxwRealCorpId":"ww64df1a47"}

//class define
  TResponData = class
  private
    FAction: string;
    FDatas: string;
    FFlag: string;
    FFormat: string;
    FMessage: string;
    FStatus: string;
    FVersion: string;
 
  protected

  published
    property Action: string read FAction write FAction;
    property Datas: string read fDatas write FDatas;
    property Flag: string read FFlag write FFlag;
    property Format: string read FFormat write FFormat;
    property Message: string read FMessage write FMessage;
    property Status: string read FStatus write FStatus;
    property Version: string read FVersion write FVersion;
  public
  end;

//
procedure TForm1.Button1Click(Sender: TObject); 
var
  MjStr, mStr: string;
rd : TResponData;
begin
//{
  mjstr := '{"status":"200","flag":"SUCCESS","message":"操作成功",' +
    '"action":"safetyLogin","version":"v1.0","format":"json","datas":' +
  '[{"sessionUuid":"0cdb276a98a24d03aad4814e9d059781","tenantCountFlag":2}]}';
//}
{  //
 mjstr:= '{"action":"safetyLogin","version":"v1.0","format":"json","status":"500",' +
    '"flag":"NOT_FOUND","message":"帐号尚未注册"}';
//}
 rd := TResponData.Create;
  mormot.core.json.ObjectLoadJson(rd, mjstr);
  showmessage(rd.Message) ;//disp OK
   showmessage(rd.Datas) ;//disp nil  ,I cannot to use ObjectLoadJson to load subclass or array class

#3 PDF Engine » Compile SynPdf error » 2023-11-22 07:12:34

loadymf
Replies: 7

when I complie synpdf,on lazarus 2.2.2 fpc3.2.2(target win32,i386 )
SynPdf.pas  Error: Identifier not found "TMetaFile"
procedure RenderMetaFile(MF: TMetaFile; ScaleX: Single=1.0; ScaleY: Single=0.0;
      XOff: single=0.0; YOff: single=0.0;
      TextPositioning: TPdfCanvasRenderMetaFileTextPositioning=tpSetTextJustification;
      KerningHScaleBottom: single=99.0; KerningHScaleTop: single=101.0;
      TextClipping: TPdfCanvasRenderMetaFileTextClipping=tcAlwaysClip);
add uses synfpcmetafile,it disp many error:
SynPdf.pas(3010,8) Error: Wrong number of parameters specified for call to "GetFontData"
font.inc(135,10) Error: Found declaration: GetFontData(LongWord):<record type>;
SynPdf.pas(3014,6) Error: Wrong number of parameters specified for call to "GetFontData"
font.inc(135,10) Error: Found declaration: GetFontData(LongWord):<record type>;
SynPdf.pas(3029,57) Error: Incompatible type for arg no. 7: Got "LongWord", expected "PDWord"
SynPdf.pas(3135,38) Error: Call by var for arg no. 3 has to match exactly: Got "PChar" expected "Byte"
SynPdf.pas(3149,38) Error: Call by var for arg no. 3 has to match exactly: Got "PChar" expected "Byte"

#4 mORMot 1 » An error occurred while I was compiling on Delphi 7 » 2023-11-13 00:23:23

loadymf
Replies: 0

function TFileBufferReader.Read(Data: pointer; DataLen: PtrInt): integer;
var Len: PtrInt;

[Fatal Error] SynTable.pas(12291): Internal error: C15309,

Board footer

Powered by FluxBB