Closed bobprog72 closed 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
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