#1 2019-05-02 12:44:00

Shadownildo
Member
From: Brazil
Registered: 2018-10-10
Posts: 36

Maybe a Possible Bug in Unserialization ObjectLoadVariant

I don't know if it's a Bug or if have to be in that way, but making some test Cases, trying to Unserialize a JSON , i found out that if i have some  Sample Objects like those underneath

type
TSampleObject1 = Class(TPersistentWithCustomCreate)
private
FField1 : Integer;
FField2 : Extended;
FField3 : TSampleObject2 ;
FField4 : String ;
procedure SetField4(Value : TSampleObject2);

published
Constructor Create;override;
property Field1 : Integer read FField1 write FField1;
property Field2 : Extended read FField3 write FField3;
property Field3 : TSampleObject2 read Field4 write SetField4;
property Field4 : String read FField2  write FField2 ;
end;

TSampleObject2 = class
private
FField5 : Integer;
FField6 : String;
FField7 : Extended;
public
property Field5 : Integer read FField5 write FField5;
property Field6 : String read FField6 write FField6;
property Field7 : Extended read FField7 write FField7;
end;

If in the Unserialization For some reason the Field3 failed to Parse, (In some Cases this type of Field Sometimes Parse, Sometimes don't) Field3 and Field4 Don't even try to parse, same goes to if The Field3 is not Created, he fail to Parse and Field4 don't even try to parse, i don't know if it's have to be in this way, But if it's really supposed to be , I'll remove the post

Offline

#2 2019-05-03 07:25:07

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Maybe a Possible Bug in Unserialization ObjectLoadVariant

I can't follow exactly what you expect.
Class parsing stop at failure, by definition - but it depends on what you call "failure", and there are options to tune the behavior.

Please don't put extensive code in the forum - see https://synopse.info/forum/misc.php?action=rules
One https://en.wikipedia.org/wiki/Minimal_working_example could be more easy to understand.

Offline

#3 2019-05-03 12:28:37

Shadownildo
Member
From: Brazil
Registered: 2018-10-10
Posts: 36

Re: Maybe a Possible Bug in Unserialization ObjectLoadVariant

ab wrote:

I can't follow exactly what you expect.
Class parsing stop at failure, by definition - but it depends on what you call "failure", and there are options to tune the behavior.

Please don't put extensive code in the forum - see https://synopse.info/forum/misc.php?action=rules
One https://en.wikipedia.org/wiki/Minimal_working_example could be more easy to understand.


Thanks for the answer !
Sorry about that Ab, for me it was not a extensive code, i will try to minimize next time. About The Parsing, doing with Datasnap and using TJSON.JsonToObject() for Unserialize, this problem don't occours , but it's much more Slower than the ObjectLoadVariant(), this is why i don't know if was a bug or just the way it has to be.

Sorry about the Bad English.

Offline

Board footer

Powered by FluxBB