andrea-magni / MARS

MARS-Curiosity Delphi REST Library
Mozilla Public License 2.0
362 stars 113 forks source link

Issue with TObject and TArray<TObject> deserialization #120

Closed bobprog72 closed 2 years ago

bobprog72 commented 2 years ago

Model:

type TParametro = class( TObject ) private FValoreParametro: string; FNomeParametro: string; public property NomeParametro : string read FNomeParametro write FNomeParametro; property ValoreParametro : string read FValoreParametro write FValoreParametro; end;

type TParametri = TArray< TParametro >;

type TUtenteParam = class( TObject ) private FKServizio: Integer; FIdServizio: string; FIdUtente: Integer; FOpzioni: TParametri; public property KServizio : Integer read FKServizio write FKServizio; property IdServizio : string read FIdServizio write FIdServizio; property IdUtente : Integer read FIdUtente write FIdUtente; property Opzioni : TParametri read FOpzioni write FOpzioni; end;

Resource: type [Path('test')] TTestDeserialization = class public [POST, Produces(TMediaType.TEXT_PLAIN)] procedure StoreUtenteParams( [BodyParam] const AUserParams: TUtenteParam ); end;

Bug: If I POST this UserParam(example) { "IdServizio": "S0001", "KServizio": 1, "IdUtente": 1, "Opzioni": [ { "NomeParametro":"ApiKey", "ValoreParametro":"prova1" }, { "NomeParametro":"SharedSecret", "ValoreParametro":"prova2" } ] }

the Opzioni array is filled with 2 object TParametro with the last JsonObject in array.

I've attached the test server application. test deserialization.zip