Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi TJsonObjectBuilder wirft Exception (https://www.delphipraxis.net/194193-tjsonobjectbuilder-wirft-exception.html)

Der schöne Günther 26. Okt 2017 18:33

Delphi-Version: 10 Seattle

TJsonObjectBuilder wirft Exception
 
Ganz unkompliziert gefragt: Was mache ich falsch?

Delphi-Quellcode:
uses System.Json.Builders, System.Json.Writers;

procedure p();
var
   writer: TJsonWriter;
   builder: TJSONObjectBuilder;
begin
   writer := nil; builder := nil;
   try
      writer := TJsonObjectWriter.Create(True);
      builder := TJSONObjectBuilder.Create(writer);

      builder.Clear();
         // Exception: EJSONCollectionBuilderError
         // This operation is not permitted without assigned callback
   finally
      builder.Free(); writer.Free();
   end;
end;

Uwe Raabe 26. Okt 2017 22:12

AW: TJsonObjectBuilder wirft Exception
 
Die Doku von
Delphi-Quellcode:
Clear
sagt:

Zitat:

Erases builder content. AResetWriter must be specified at builder constructur call, which will reset underlying builder stream.
Du solltest also den überladenen constructor aufrufen und dem die benötigten Methoden mitgeben.


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:33 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz