You are not logged in.
I'm not sure that the problem is there, but I got stuck (or tired) in debugging.
It seems that the problem appears only for big JSON arrays. Procedure _JL_DynArray exits with an invalid context result after guessing the array count(=0).
Considering the logic of the code (like result := -result and so on) I tried to change
function JsonArrayCount(P, PMax: PUtf8Char): integer;
begin
result := -1;
...
It helps for the huge input but breaks the parsing of smaller arrays...
Offline
For a huge array, JsonArrayCount() should return a negative number, not 0.
Then _JL_DynArray() should use the abs() value as initial guess for its array size, then grow up on need.
The problem was not if the JSON array was big (I did test that), but if the first item of the JSON array was big (I didn't test it).
Then PMax was reached before the count was 1, and it falsely returned 0.
Should be fixed now.
Thanks for the input!
Offline