#1 2022-01-31 10:37:51

Stemon63
Member
Registered: 2016-10-24
Posts: 49

Mormot 2 - RetrieveListJson "compact" features

Hi,
in MOrmot 2, it's possibile to add some options to RetrieveListJson() for "compact" Json result?
I intend similar to the [ToNonExpandedJson] for a packed "CSV" format and [DontStoreVoid] for smaller Json result (alternative of course).
I want obtain best performance possible without convert Json result in TDocVariant with performance penalty, and for response with a compact Json result, where possible.
Thanks a lot!!

Offline

#2 2022-01-31 13:03:03

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

Re: Mormot 2 - RetrieveListJson "compact" features

IIRC RetrieveListJson() has aForceAjax=false by default which returns the "compact" JSON result.
You can also force it by setting TRestServer.NoAjaxJson := true.

Note that you have already an IRestOrm.RetrieveDocVariantArray() method to create a TDocVariant.

Offline

#3 2022-01-31 16:45:30

Stemon63
Member
Registered: 2016-10-24
Posts: 49

Re: Mormot 2 - RetrieveListJson "compact" features

It seems that only  aForceAjax=false by default don't works.
Instead with TRestServer.NoAjaxJson := true it works well. Thanks a lot!

A different serialization:
There is a way for obtain a direct serialization for a  JSON with "[DontStoreVoid]" option for a
IRestOrm.RetrieveDocVariantArray() (or other Retrieve...)? I don't find this capability natively.
Naturally the fastest way possible...

Thanks in advance!

Offline

#4 2022-01-31 18:47:51

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

Re: Mormot 2 - RetrieveListJson "compact" features

There is no such method directly.
Because in practice, it is likely to be slower than always putting all fields.

My guess is that a custom method working at ORM level, using TOrmPropInfo.IsValueVoid and TOrmPropInfo.GetVariant could help, if you really need it.

Offline

#5 2022-02-01 11:25:45

Stemon63
Member
Registered: 2016-10-24
Posts: 49

Re: Mormot 2 - RetrieveListJson "compact" features

OK, perfect.
Thanks a lot :-)

Offline

Board footer

Powered by FluxBB