IJsonDocument.WriteToFile

Syntax

WriteToFile(FileName: String; [Options: JsonFormatOptions =0]);

Parameters

FileName. JSON file path and name.

Options. View format when writing.

Description

The WriteToFile method writes JSON structure to the specified file.

Example

Sub UserProc;
Var
    NewJSON: IJsonObjectBuilder;
    Doc: IJsonDocument;
Begin
    NewJSON := New JsonObjectBuilder.Create;
    NewJSON.AddBoolean("Bool"True);
    NewJSON.AddDouble("Double"3.14);
    NewJSON.AddInteger("Integer"100);
    NewJSON.AddNull("Null");
    NewJSON.AddString("String""Test JSON");
    NewJSON.AddBoolean("Bool"True);
    // Save to file
    Doc := New JsonDocument.Create;
    Doc.RootElement := NewJSON.Build;
    Doc.WriteToFile("d:\Work\Json\testfile.json");
End Sub UserProc;

After executing the example a new JSON structure with a set of elements is created. The structure will be saved to the specified file.

See also:

IJsonDocument