Skip to content

fcl-json option SupressExceptionOnSave

this is Flush method:

procedure TJSONConfig.Flush;
..
begin
  if Modified then
    begin
    F:=TFileStream.Create(FileName,fmCreate);
    Try
      if Formatted then
        S:=FJSON.FormatJSON(Formatoptions,FormatIndentSize)
      else
        S:=FJSON.AsJSON;
      if S>'' then
        begin
        F.WriteBuffer(S[1],Length(S));  
        F.Flush;
        end;
    Finally
      F.Free;
    end;
    FModified := False;
    end;
end;

my app has about 10 JsonConf objects, and I need to supress exceptions on saving json-files. do it for all 10 places? bad! let's add option joSupressExceptionOnSave.

  TJSONOption = (joUTF8,joStrict,joComments,joIgnoreTrailingComma,joIgnoreDuplicates,joBOMCheck,joSingle);

when on, Flush() will surround saving in empty try/exept. do you agree it's good change?

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information