Skip to content

Commit ec529de

Browse files
author
Arnaud Bouchez
committed
core: completed DocVariantToObject()
to support class instance properties
1 parent 53bee75 commit ec529de

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/core/mormot.core.variants.pas

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5665,6 +5665,19 @@ function DocVariantToObject(var doc: TDocVariantData; obj: TObject;
56655665
var
56665666
p: PtrInt;
56675667
prop: PRttiCustomProp;
5668+
dv: PDocVariantData;
5669+
5670+
procedure DoComplex;
5671+
var
5672+
json: RawUtf8;
5673+
valid: boolean;
5674+
begin
5675+
json := dv^.ToJson;
5676+
if (json <> '') and
5677+
(json <> 'null') then
5678+
PropertyFromJson(prop, obj, pointer(json), valid, JSONPARSER_TOLERANTOPTIONS);
5679+
end;
5680+
56685681
begin
56695682
if doc.IsObject and
56705683
(doc.Count > 0) and
@@ -5676,7 +5689,10 @@ function DocVariantToObject(var doc: TDocVariantData; obj: TObject;
56765689
begin
56775690
prop := objRtti.Props.Find(doc.Names[p]);
56785691
if prop <> nil then
5679-
prop^.Prop.SetValue(obj, doc.Values[p]);
5692+
if not prop^.Prop.SetValue(obj, doc.Values[p]) then
5693+
if (prop^.Value.Kind = rkClass) and
5694+
_Safe(doc.Values[p], dv) then
5695+
DoComplex;
56805696
end;
56815697
result := true;
56825698
end

src/mormot.commit.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
'2.3.9263'
1+
'2.3.9264'

0 commit comments

Comments
 (0)