mORMot and Open Source friends
View Ticket
Not logged in
2014-06-27
11:57 Closed ticket [954d9f0fd9]: Let TTextWriter.RegisterCustomJSONSerializer use the advanced RTTI available since Delphi 2010 plus 6 other changes artifact: e4b9b7cce5 user: root
2014-04-27
07:14 New ticket [954d9f0fd9]. artifact: 1a1dca7462 user: ab

Ticket Hash: 954d9f0fd91de3b9afdfc2c14cf23ebc5f8f2bde
Title: Let TTextWriter.RegisterCustomJSONSerializer use the advanced RTTI available since Delphi 2010
Status: Closed Type: Feature_Request
Severity: Important Priority: Immediate
Subsystem: mORMot Resolution: Implemented
Last Modified: 2014-06-27 11:57:58
Version Found In: 1.18
Description:
As identified, records can be serialized via some manual text information. It works fine, but needs manual handling of the type information.

With versions of Delphi < 2010, there is not enough information to find out the exact record layout.
Even TContactData = array of Integer do not let TypeInfo(TContactData) have enough information (it states "a dynamic array of 4 bytes of data which does not have any complex type" - but it may be a cardinal, a pointer, a TObject, or four bytes, or one byte, one word, and one byte....).

Note that the FreePascalCompiler (and therefore Lazarus) have the same limited level of information.

This feature request is about using the "new RTTI", available since Delphi 2010, to retrieve the record layout. It may be implemented in SynCommons.pas directly, letting the RTTI unit of the VCL be used in the implementation section.
Of course, it won't be available for older versions of the compiler, neither with FPC.

User Comments:
root added on 2014-06-27 11:57:58:

It has been implemented for Delphi 2010 and up.

See this blog article for details.