We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
note: The latest FPC already supports RTTI for records (https://gitlab.com/freepascal.org/fpc/source/-/issues/40798)
program project1; {$ifdef FPC} {$mode delphi} {$else} {$APPTYPE CONSOLE} {$endif} {$I mormot.defines.inc} uses {$I mormot.uses.inc} {$IFDEF DCC}System.{$ENDIF}Classes, {$IFDEF DCC}System.{$ENDIF}SysUtils, mormot.core.base, mormot.core.rtti, mormot.core.variants, mormot.core.json; type {$RTTI EXPLICIT PROPERTIES([vcPublished]) FIELDS([vcPublic]) METHODS([])} TEFloor = packed record el: WORD; fl: array of Byte; end; TECtrl = packed record ecid: WORD; expd: array of Byte; efl: array of TEFloor; icod: UTF8String; pt: array of Integer; adv: BYTE; end; TECtrls = Array of TECtrl; var tmp1, tmp2: UTf8String; ec: TECtrls; begin tmp1 := '[{"ecid":12,"expd":[80,17,18],"efl":[{"el":0,"fl":[1,2]},{"el":1,"fl":[4,5]}],"icod":"123456","pt":[1,2,3],"adv":5}]'; DynArrayLoadJson(ec, tmp1, TypeInfo(TECtrls)); WriteLn(tmp1); tmp2 := DynArraySaveJson(ec, TypeInfo(TECtrls)); WriteLn(tmp2); if tmp1 = tmp2 then WriteLn('ok') else WriteLn('failed'); end.
The above programs are compiled with fpc and run as follows.
# fpc project1.pas -Fic:\mORMot2\src -Fuc:\mORMot2\src\core;c:\mORMot2\src\lib -Flc:\mORMot2\static\i386-win32 Free Pascal Compiler version 3.3.1 [2024/06/26] for i386 Copyright (c) 1993-2024 by Florian Klaempfl and others Target OS: Win32 for i386 Compiling project1.pas Linking project1.exe 895 lines compiled, 0.3 sec, 563504 bytes code, 20004 bytes data # project1 [{"ecid":12,"expd":[80,17,18],"efl":[{"el":0,"fl":[1,2]},{"el":1,"fl":[4,5]}],"icod":"123456","pt":[1,2,3],"adv":5}] [] failed
The above program is compiled by delphi and the results are as follows
# dcc32 project1.pas -Ic:\mORMot2\src;c:\mORMot2\static\i386-win32 -Uc:\mORMot2\src\core;c:\mORMot2\src\lib -NSSystem;Winapi Embarcadero Delphi for Win32 compiler version 36.0 Copyright (c) 1983,2024 Embarcadero Technologies, Inc. c:\mORMot2\src\mormot.defines.inc(792) c:\mORMot2\src\mormot.uses.inc(50) project1.pas(56) 897 lines, 0.11 seconds, 1439256 bytes code, 103032 bytes data. # project1.exe [{"ecid":12,"expd":[80,17,18],"efl":[{"el":0,"fl":[1,2]},{"el":1,"fl":[4,5]}],"icod":"123456","pt":[1,2,3],"adv":5}] [{"ecid":12,"expd":[80,17,18],"efl":[{"el":0,"fl":[1,2]},{"el":1,"fl":[4,5]}],"icod":"123456","pt":[1,2,3],"adv":5}] ok
The text was updated successfully, but these errors were encountered:
experimental TRttiInfo.RecordAllFields support on FPC trunk
c0dbef4
- as asked by #266
Please try above commit.
I don't have FPC trunk installed yet, but I will try to.
Sorry, something went wrong.
project1.pas adds the following statement before TEFloor = packed record.
{$RTTI EXPLICIT PROPERTIES([vcPublished]) FIELDS([vcPublic]) METHODS([])}
Recompile and run, everything is fine.
You were amazing.
Thank you for your quick response and quick repair.
No branches or pull requests
System Information
note: The latest FPC already supports RTTI for records (https://gitlab.com/freepascal.org/fpc/source/-/issues/40798)
Example Project
The above programs are compiled with fpc and run as follows.
Relevant 3rd party information
The above program is compiled by delphi and the results are as follows
The text was updated successfully, but these errors were encountered: