#1 2018-07-16 09:06:39

ComingNine
Member
Registered: 2010-07-29
Posts: 294

Problem when deserializing class with array prop backed by methods.

As shown in the sample, a class with an array prop backed by methods is serialized and then deserialized. The deserialization of the class fails because, since GetDynArray of that prop sets DynArray.fValue to nil, DynArray.LoadFromJSON concludes all of the remaining JSON is invalid and jumps to the end of the JSON. It would seem more proper if DynArray.LoadFromJSON only skips the very array property backed by methods instead of all the remaining JSON. Could you help to comment ?

Offline

#2 2018-07-16 14:40:08

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

Re: Problem when deserializing class with array prop backed by methods.

Isn't it failing because both properties are using the same actual storage?

Offline

#3 2018-07-17 02:39:58

ComingNine
Member
Registered: 2010-07-29
Posts: 294

Re: Problem when deserializing class with array prop backed by methods.

Dear ab, it seems to me that the deserialization of the class fails because GetDynArray of an array prop backed by methods will set DynArray.fValue to nil, and consequently "From := DynArray.LoadFromJSON()" concludes all of the remaining JSON is invalid and jumps to the end of the JSON. Could you help to comment ?

Furthermore, the gist sample has been clarified. As shown in DeserializeClassWithPropertyBackedByMethods2.dpr, there is no two properties pointing the actual storage.

Last edited by ComingNine (2018-07-17 02:40:35)

Offline

Board footer

Powered by FluxBB