Recent

Author Topic: Something buggy about build-in JSON parser OR the documentation  (Read 235 times)

KennethH

  • New member
  • *
  • Posts: 9
Something buggy about build-in JSON parser OR the documentation
« on: February 19, 2025, 10:02:02 pm »
Hope this is the correct space for this note

https://wiki.freepascal.org/JSON says:
Quote
This implementation adheres strictly to the RFC 4627 guidelines above and does not allow deviation from the specification.

The same wiki also says:
Quote
allows trailing comma after the last member of an array

After some problems consuming user-created json, I feel like the former statement is true and the other case is incorrect

I was able to bypass this problem entirely using https://forum.lazarus.freepascal.org/index.php/topic,46533.0.html but I think the "Strict" member is not getting referenced

Code: Pascal  [Select][+][-]
  1. procedure MyJSONParserHandler(AStream: TStream; const AUseUTF8: Boolean; out
  2.   Data: TJSONData);
  3.  
  4. Var
  5.   P : TJSONParser;
  6.  
  7. begin
  8.   Data:=Nil;
  9.   P:=TJSONParser.Create(AStream,AUseUTF8);
  10.   P.Strict := False;   //This line is my attempt to get that comma to parse
  11.   try
  12.     Data:=P.Parse;
  13.   finally
  14.     P.Free;
  15.   end;
  16. end;
  17.  



 

TinyPortal © 2005-2018