WriteToFile(FileName: String; [Options: JsonFormatOptions =0]);
WriteToFile(FileName: String; Options: Prognoz.Platform.Interop.ForeSystem.JsonFormatOptions);
FileName. JSON file path and name.
Options. View format when writing.
The WriteToFile method writes JSON structure to the specified file.
Add links to the ForeSystem (for the Fore.NET example) system assembly.
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.Root := NewJSON.Build;
Doc.WriteToFile("d:\Work\Json\testfile.json");
End Sub UserProc;
Imports Prognoz.Platform.Interop.ForeSystem;
Public Shared Sub Main(Params: StartParams);
Var
NewJSON: IJsonObjectBuilder = New JsonObjectBuilderClass();
Doc: IJsonDocument = New JsonDocumentClass();
Begin
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.Root := NewJSON.Build();
Doc.WriteToFile("d:\Work\Json\testfile.json", JsonFormatOptions.jfoDefault);
End Sub;
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: