You are not logged in.
Hi,
I'm using RecordLoadJSON / DynArrayLoadJSON with custom serialization
(TTextWriter.RegisterCustomJSONSerializerFromText)
and I'm facing a problem with a JSON object like this:
{
"type": 1,
"name": "myName"
}
the problem is that I cannot map it to this
type
TDBRec_myRec = packed record
type: Integer; // <-- error! "type" is a reserved keyword
name: RawUTF8;
end;
const
__TDBRec_myRec = 'type: Integer; name: RawUTF8';
Is there some way to tell the serializer to map JSON "type" to some other record field?
Thank you very much.
Last edited by yankee (2017-12-11 16:09:33)
Offline
The name in the text definition is not required to map the field name in the record.
So you can write:
type
TDBRec_myRec = packed record
atype: Integer;
name: RawUTF8;
end;
const
__TDBRec_myRec = 'type: Integer; name: RawUTF8';
Offline
Thank you!!
I didn't catch that mapping is positional.
Offline