You are not logged in.
Pages: 1
I Receive TObjects from my Server via SOA Interface.
The Object contains TDateTime Fields.
One of these date fields is null (0)
On the Client site these Objects are Create by RTTI calls in mORMot2.
I got an error if DateField = 0
As Patch i modified mormot.core.rtti.pas Line 3884f:
f := _Iso8601ToDateTime(u);
// if f = 0 then // itSDS Datetime kann leer sein wenn es "Null" auf dem Server ist.
// exit;
SetFloatProp(Instance, f);
end
Can you add this to the Repo - if my Patch is right ?
Rad Studio 12.1 Santorini
Offline
I debugged the lines and the input Value is "" (Empty String) for the DateTime Property.
What i'm wondering about is that the parser calls different property parser for my DateTime property.
In case of my "ausgabedatum" Property it calls procedure TJsonParserContext.ParsePropComplex(Data: pointer);
And for one of my other DateTime Property "GeloeschtAm" it calls procedure _JL_DateTime(Data: PDateTime; var Ctxt: TJsonParserContext); the Value is in both Cases = ""
The Error displayed is:
EInterfaceFactory mit Meldung 'IDomV.GetG failed parsing AArray: TArray<DomVTypes.TGObject> from input JSON'. Prozess xyz.exe (1312) (Generated in mormot.core.interfaces line 2665)
Last edited by itSDS (2022-11-29 16:55:13)
Rad Studio 12.1 Santorini
Offline
There is 1 difference: property ausgabedatum has a setter defined (setausgabedatum) then _JL_DateTime is not called but Ctxt.ParsePropComplex because Prop^.OffsetSet = -1 and ParsePropComplex calls my Patched TRttiProp.SetValue which tries to set my Ausgabedatum to "" -> resulting in an error.
and here is the json:
...
Vertrag:null,Standrohr:{ServerState:4,Anlagedatum:"2022-11-26T09:15:25",LetzteAenderung:"2022-11-26T09:15:25",GeloeschtAm:"",GeraetID:1916,Mandant:null,Geraetetyp:null,Kontrolle:null,Vertrag:null,Standrohr:null,Status:0,Lagerort:"",Seriennummer:"",Baujahr:0,Hersteller:"",Beschreibung:"",Identifikation:"",Notiz:"",Groesse:"",Bauform:"",Eichjahr:0,NextEichjahr:0,Zaehlerstand:0,Ausgabedatum:""},Status
...
Rad Studio 12.1 Santorini
Offline
Instead of using this argument "AArray: TArray<DomVTypes.TGObject>" in the interface definition of the function, have you tried it this way "out AArray: TGObjectObjArray"?
type
TGObjectObjArray = array of DomVTypes.TGObject;
initialization
Rtti.RegisterObjArrays([TypeInfo(TGObjectObjArray), DomVTypes.TGObject]);
With best regards
Thomas
Offline
example for the TObject i use as parameter:
TBaseObject = class(TObject)
private
fAnlagedatum : TDateTime;
..
published
property Anlagedatum : TDateTime read fAnlagedatum;
end;
TDerivedObject = class(TBaseClass)
protected
fAusgabedatum : TDateTime;
private
procedure SetAusgabedatum(const AAusgabedatum : TDateTime);
published
property Ausgabedatum : TDateTime read fAusgabedatum write SetAusgabedatum;
Last edited by itSDS (2022-11-29 19:58:44)
Rad Studio 12.1 Santorini
Offline
@tbo
My Real Interface looks like this:
TDObjArray = TArray<TDerivedObject >;
IDomGverwaltung = interface(IInvokable)
..
function GetDerived(out ADerived : TDObjArray) : TresultRec;
..
TInterfaceFactory.RegisterInterfaces([TypeInfo(IDomGverwaltung)]);
Last edited by itSDS (2022-11-29 20:03:23)
Rad Studio 12.1 Santorini
Offline
Great!
Now, I understand.
Please try https://github.com/synopse/mORMot2/commit/00ed9a34
Online
Thank - that's it
Rad Studio 12.1 Santorini
Offline
Pages: 1