You are not logged in.
Hello,
I have old code that I am converting to use mORMot2 and I have quite a lot code like below
const
__TTransaction = 'TxnId Int64 TxnTypeId Int64';
...
initialization
TTextWriter.RegisterCustomJSONSerializerFromText(TypeInfo(TIngenicoResult), __TTransaction).Options := [soReadIgnoreUnknownFields];
I could not figure how I can put this so it will work the same as before.
Any help is appreciated.
Thanks & Regards,
Ertan
Offline
perhaps this info in mormot.core.text.pas can help:
// - note: mORMot 1.18 TTextWriter.RegisterCustomJSONSerializerFromText()
// are moved into Rtti.RegisterFromText() as other similar methods
P.S.
We also have contact with Ingenico
Last edited by danielkuettner (2024-08-07 14:36:20)
Offline
Thank you. In file search returns so many results and repeated filenames that it seems I missed that note.
So, how can I tell mORMot2 to read ignore unknown fields?
Offline
I couldn't understand what I read from the document so I did some tests.
Base information
type
TTransaction = packed record
TxnId: Int64;
TxnTypeId: Int64;
end;
const
__TTransaction = 'TxnId Int64 TxnTypeId Int64';
var
Json: string = '{"test":"additional field","TxnId":1,"TxnTypeId":2}';
...
initialization
Rtti.RegisterFromText(TypeInfo(TTransaction), __TTransaction);
Tests I did are as follows:
// Test1 - no dialog displayed
if mormot.core.json.RecordLoadJson(Test, Json, TypeInfo(TTransaction), nil, False) then
ShowMessage('OK');
// Test2 - displays OK dialog
if mormot.core.json.RecordLoadJson(Test, Json, TypeInfo(TTransaction)) then
ShowMessage('OK');
Test2 is what I currently have in my unit using Synopse.pas.
It seems I don't need any additional code change as "Tolerant = true" as default and that is what I needed.
Thanks & Regards,
Ertan
Offline