Neslib.Json icon indicating copy to clipboard operation
Neslib.Json copied to clipboard

Stringifying JSON array without indentation triggers error

Open MAC420965 opened this issue 3 years ago • 1 comments

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.

MAC420965 avatar Jul 06 '22 15:07 MAC420965

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.

neslib avatar Jul 06 '22 17:07 neslib

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

sebomozd avatar Oct 12 '22 20:10 sebomozd

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.

neslib avatar Oct 14 '22 15:10 neslib