You are not logged in.
Hi,
is it possible to serialize a record like this with definition RegisterFromText and without changing the record type (TTest) definition?
type TEnum = (eTagUnknown,eTagOne,eTagTwo)
TTest = record
id: cardinal;
test: string;
prices: array[1..3] of double;
tags[eTagOne..eTagTwo] of integer;
end;
const __TTest = 'id:cardinal;test:string;prices: array of double;tags: array of integer';
I have tried registriation with:
Rtti.RegisterTypes([TypeInfo(TEnum)]);
Rtti.RegisterFromText(TypeInfo(TTestRecord),__TTest);
but i get the error/exception on RegisterFromText:
Rtti.RegisterFromText(TTestRecord): text definition covers 16 bytes, but RTTI defined 40
Offline
You can't mix dynamic arrays (array of) and static arrays (array[1..3] of), because their are NOT the same type in memory and in the RTL.
And static arrays are not yet supported in RegisterFromText().
What you could do is manually expand the static arrays:
const __TTest = 'id:cardinal;test:string;price1,price2,price3: double; tagOne,tagTwo:integer';
But it won't make the expected JSON I guess.
Offline