File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -3735,6 +3735,10 @@ function DocDictCopy(const v: variant): IDocDict; overload;
37353735function DocDictCopy (const dv: TDocVariantData;
37363736 model: TDocVariantModel): IDocDict; overload;
37373737
3738+ // / create a self-owned IDocDict/IDocList from a JSON object/array content
3739+ // - if json is something else than an object or array, returns nil
3740+ function DocAny (const json: RawUtf8; model: TDocVariantModel): IDocAny;
3741+
37383742var
37393743 // / default TDocVariant model for IDocList/IDocDict
37403744 DocAnyDefaultModel: TDocVariantModel = mFastFloat;
@@ -11613,6 +11617,22 @@ function DocDictFromKeys(const keys: array of RawUtf8; const value: variant;
1161311617 result := d;
1161411618end ;
1161511619
11620+ { IDocAny factories functions }
11621+
11622+ function DocAny (const json: RawUtf8; model: TDocVariantModel): IDocAny;
11623+ begin
11624+ result := nil ;
11625+ case GetFirstJsonToken(pointer(json)) of
11626+ jtObjectStart:
11627+ result := DocDict(model);
11628+ jtArrayStart:
11629+ result := DocList(model);
11630+ else
11631+ exit;
11632+ end ;
11633+ result.SetJson(json);
11634+ end ;
11635+
1161611636
1161711637{ TDocAny }
1161811638
Original file line number Diff line number Diff line change 1- '2.3.13156 '
1+ '2.3.13157 '
You can’t perform that action at this time.
0 commit comments