[Solved] JSONTools error while parsing lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- lainz · 2021-06-02 14:36 This is the json file https://www.dropbox.com/s/4i8o9gpsjdr1pd2/file.json?dl=0 This is our copy of jsontools.pas https://www.dropbox.com/s/ux1ai5q2zublt1p/jsontools.pas?dl=0 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);var  j: TJSONNode;begin  j := TJSONNode.Create;  j.LoadFromFile('file.json');  j.Free;end; Its a valid JSON and it says it can't parse. I'm not an expert on parsing, only I know very basic stuff about it. Any ideas? ---------------------------------------------------------------------- sstvmaster · 2021-06-02 14:51 I have no idea, but look at the link: https://wiki.freepascal.org/fcl- json#From_JsonViewer And in the lazarus folder under tools there is an tool called: jsonviewer ---------------------------------------------------------------------- lainz · 2021-06-02 14:57 Quote from: sstvmaster on June 02, 2021, 04:51:51 pmI have no idea, but look at the link: https://wiki.freepascal.org/fcl- json#From_JsonViewer And in the lazarus folder under tools there is an tool called: jsonviewer Yes but our entire project uses jsontools, not fpcjson ---------------------------------------------------------------------- engkin · 2021-06-02 15:55 It fails at the \\" as in: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   s:='[{"snombre":"PANTENE ENJ L.Y SEDOSO 400ML\\","rpreciou":285}]'; While this works: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   s:='[{"snombre":"PANTENE ENJ L.Y SEDOSO 400ML","rpreciou":285}]'; Tested using: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   j := TJSONNode.Create;  j.Parse(s);  j.Free; Your file has one instance of \\, remove it and it'll work. Changing NextToken: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function NextToken(var C: PChar; out T: TJsonToken): Boolean;.....  if C^ = '"'  then  begin    Inc(C);    repeat      if C^ = '\' then      begin      Inc(C);        if C^ = '\' then          Inc(C)        else if C^ = '"' then          Inc(C) ---------------------------------------------------------------------- lainz · 2021-06-02 16:10 Many thanks engkin ---------------------------------------------------------------------- sysrpl · 2021-07-31 12:48 This issue has been fixed in a updated release.