Enhanced RTTI support for records and dynamic arrays was added by this commit.
The documentation has been enhanced in synch!
Please ensure that you downloaded the latest SAD 1.18 pdf revision!
Serialization for older Delphi versions
Sadly, the information needed to serialize a record
is
available only since Delphi 2010.
If your application is developped on any older revision (e.g. Delphi 7,
Delphi 2007 or Delphi 2009), you won't be able to automatically serialize
records
as plain JSON objects directly.
You have several paths available:
- By default, the
record
will be serialized as binary, and encoded as Base64 text; - Or you can define method callbacks which will write or read the data as you expect;
- Or you can define the
record
layout as plain text.
Note that any custom serialization (either via callbacks, or via text
definition), will override any previous registered method, even the mechanism
using the enhanced RTTI.
You can change the default serialization to easily meet your requirements.
For instance, this is what SynCommons.pas
does for any
TGUID
content, which is serialized as the standard JSON text
layout (e.g. "C9A646D3-9C61-4CB7-BFCD-EE2522C8F633"
), and not
following the TGUID record
layout as defined in the RTTI , i.e.
"D1":12345678,"D2":23023,"D3":9323,"D4":"0123456789ABCDEF"
- which
is far from convenient.
U