neslib / Neslib.Json

Fast and memory-efficient JSON for Delphi
Other
79 stars 23 forks source link

Stringifying JSON array without indentation triggers error #13

Closed MAC420965 closed 1 year ago

MAC420965 commented 2 years ago

program StringifyJsonArray;

{$APPTYPE CONSOLE}

{$R *.res}

uses System.SysUtils, Neslib.Json {latest version};

var doc: IJsonDocument; u: utf8string;

begin try doc := TJsonDocument.Parse('{"i":[-1,0,1]}'); u := doc.ToJson(false); // works if parameter is changed to true; tested with Delphi 11.1 and Win64 as target WriteLn(Utf8ToString(u)); except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; ReadLn; end.

neslib commented 2 years ago

Could you elaborate on the error. Is it an exception? Where in the source code is the error raised?

I tried to reproduce it with you code snippet but I cannot. I am also using Delphi 11.1. I tried the Win64 both with and without the JSON_UTF8 define and with and without the JSON_STRING_INTERNING define, but I couldn't reproduce the error with any of these combinations.

sebomozd commented 1 year ago

I have this exception too, ERangeError in Neslib.Json.IO on line 1696, FIndentation is empty.

neslib commented 1 year ago

Sorry, I created this project with Range Checking turned off. I found a couple of ERangeError's when I turned range checking on. I think I got them all, but let me know if you still encounter other instances.

I also updated the Neslib submodule accordingly, so be sure you update the submodule as well or pull this repo recursively.