You are not logged in.
Pages: 1
Hello ab,
I am study the new mormot2 json IDocDict,IDocList it is very usefull to handle json structure by interfaces.
I see DocDict('{}') and DocList('[]') but how load a json string that do not know if is object or array.
Can I build a DocAny that load object or array json string?
Thanks
Offline
IDocDict is a dictionary/object.
IDocList is a list/array.
If you want to store anything use a variant.
And behind the scene both IDocDict/IDocList store their data within a custom variant type - a TDocVariant.
Offline
Thank you ab
i create bellow simple DocAny function
if you adopt it add it at mormot.core.variants
function DocAny(const json: RawUtf8; model: TDocVariantModel = mFastFloat): IDocAny;
begin
if Copy(json,1,1) = '[' then
result:= DocList(model)
else
result := DocDict(model);
result.SetJson(json);
end;Offline
Ah ok now I understand.
You want a IDocAny factory class.
Please try with
https://github.com/synopse/mORMot2/commit/e712c2f6f
Offline
Pages: 1