You are not logged in.
For code like this (Expanded parameter is "True"):
LJSON := aProps.Execute(SQL,[]).FetchAllAsJSON(True);
for empty "aProps.Execute(SQL,[])" result the proper result of FetchAllAsJSON is:
[]
instead of:
{
"fieldCount": 4,
"values":
[
"id",
"x",
"y",
"z"
],
"rowCount": 0
}
for Count >= 1 result of "Expanded" FetchAllAsJSON is ok.
Patch attached:
https://drive.google.com/file/d/0B4PZhd … sp=sharing
best regards,
Maciej Izak
best regards,
Maciej Izak
Offline
Maybe we need additional option for empty "[]" result? Current state can be problematic for some non-mORMotish clients.
best regards,
Maciej Izak
Offline
I guess this is not difficult to let the client handle it.
If FetchAllAsJSON returns a { ... } JSON object, and not a [ .... ] JSON array, just handle the { .... } JSON as a void [] array.
Offline
Hi,
I also intercede for the Maciej proposal.
I have to go to new version of mormot and I have to treat the result of FetchallToJSON(true) in many places - I know it's not difficult, but it makes imho more sense to return every time the same type
for Expanded = true i would like to expect allways Array []
for Expanded = false i would like to expect allways Object {}
Offline
Did you try with the latest version of the framework?
We introduced ClientKind/ClientWriteAsJsonNotAsString feature some weeks ago, which re-format the output if the request comes from a browser (AJAX).
Offline
Ok, thanks a lot for tip, I will take a look at it
Offline
hm, so nothing - it doesn't help me...
I mainly use fetchAllToJSON for the results of MSSQL queries,further I perform a little bit more complicated calculations using these JSON objects and mormotize only the result of calculation.
Offline