WriteToString([Options: JsonFormatOptions =0]);
WriteToString(Options: Prognoz.Platform.Interop.ForeSystem.JsonFormatOptions);
Options. View format when writing.
The WriteToString method returns string view of JSON structure.
Add links to the ForeSystem (for the Fore.NET example) system assembly.
Function CreateJson: String;
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);
// Get string view
Doc := New JsonDocument.Create;
Doc.Root := NewJSON.Build;
Return Doc.WriteToString;
End Function CreateJson;
Imports Prognoz.Platform.Interop.ForeSystem;
Function CreateJson(): String;
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);
// Get string view
Doc.Root := NewJSON.Build();
Return Doc.WriteToString(JsonFormatOptions.jfoDefault);
End Function;
The specified function creates a new JSON structure with a set of elements. The function results in a string view of the obtained JSON structure.
See also: