You are not logged in.
Pages: 1
A 3rd party logged an issue when consuming one of my rest server's functions. I tested and confirmed it on Mormot 1.18.6261. Not sure how to resolve it. Any suggestions would be welcome.
In my interfaces, I use the following type as an input parameter:
type TStringDataSet = array of TStringDynArray;
...
function Test(const ID: Integer; const Data: TStringDataSet): TServiceCustomAnswer;
When a POST is done using the following json body, the call succeeds and the data is correctly parsed and handled:
{"Data": [["ItemA1", "ItemA2"],["ItemB1","ItemB2"]], "ID":12}
However, when the json is formatted to include either a line break or spaces between the opening square bracket of Data and its first item, a 406 Not Acceptable error is returned. The json is still valid. Sample json causing the issue:
{"Data": [
["ItemA1", "ItemA2"],["ItemB1","ItemB2"]], "ID":12}
... or ...
{"Data": [ ["ItemA1", "ItemA2"],["ItemB1","ItemB2"]], "ID":12}
Is this something that the mormot parser should be able to handle, or is it something that I'll need a custom serializer for?
Offline
Thanks @ab, I'll try to find it. It looks like the issue is in SynCommons.pas in the function TDynArray.LoadFromJSON function (around line 50270). I'll try to isolate it further and provide a more precise test scenario.
in mORMot.pas, in function TServiceMethodExecute.ExecuteJson at line 60667 the following code is called:
smvDynArray: begin
Par := fDynArrays[IndexVar].Wrapper.LoadFromJSON(Par);
for the correct json, Par has a value, and for the incorrect json, Par is nil. In this scenario, the Par value that gets sent to LoadFromJSON looks like this when the function succeeds:
' [["ItemA1", "ItemA2"],["ItemB1","ItemB2"]], "ID'
and like this when it fails:
' [ ["ItemA1", "ItemA2"],["ItemB1","ItemB2"]], "ID'
Last edited by squirrel (2021-04-06 10:24:36)
Offline
It looks like another GotoNextNotSpace() might be needed in SynCommons.pas in the function TDynArray.LoadFromJSON function before line 50300, since that is where it gets the space value instead of the next [ character. Unfortunately I dont know the code well enough to know the impact of changes there.
Interesting is that in all scenarios, JSONArrayCount return the correct count.
Last edited by squirrel (2021-04-06 10:39:00)
Offline
Please check https://synopse.info/fossil/info/6bb518fb77
mORMot 2 is not concerned I guess - its TJsonParserContext.ParseArray() method in mormot.core.json.pas seems correct with such input.
Online
That works perfectly :-)
Thanks @ab. This is seriously impressive support.
Offline
Pages: 1