Suggested fix for uROJSONParser

Hi guys, been doing some work on uROJSONParser today and I suggest you review TROJSONValue.IntLoadFromStream to support a trailing comma ( , ) in an array. Its common to see servers output such a stream and javascript in the browser seems to handle it. Javascript in a browser seems to handle this as it should be ignored. At the very least, you should put a null item on the end of the array if re-factoring the entire code is too hard so at least it doesn’t crash trying to turn ] into a number.

else if lChar = ']' then begin // array
else begin // number
  AsNumber:= ReadNumber(AStream);

let x = [1,2,3,4,5,];
x.forEach(function(value) { console.log(value); } );

let x = [1,2,3,4,5,null];
x.forEach(function(value) { console.log(value); } );


from :

as for me, it doesn’t allow to have empty value like [1,2,3,4,5,]

even Delphi std classes doesn’t accept [1,2,3,4,5,]:

try it by yourself:

program Project3;
{$R *.res}
  s = '[1,2,3,4,5,]';
  TJSonObject.ParseJSONValue(s, true, true);

I wouldn’t use the delphi library as a guide to anything. Try it in chrome and you will see. If it works in chrome and therefore in NodeJS, then that’s the standard :slight_smile:
And its the same in Firefox and Spidermonkey, so therefore, that’s just how it is.
The reason we use your library instead of the Delphi one is because the Delphi one is rubbish.


according to :

IMHO, official standard has priority under Chrome & Co

And that’s why we haven’t renewed our license in 3 years :slight_smile:

Agree we should support this (and it should NOT result in an extra null item, IMHO)

Logged as bugs://E26699.

bugs://E26699 was closed as fixed.

1 Like