IJsonDocument.WriteToStream

Syntax

WriteToStream(Stream: IIOStreamSys; [Options: JsonFormatOptions =0])

Parameters

Stream. Stream, to which JSON structure is to be saved.

Options. View format when writing.

Description

The WriteToStream method writes JSON structure to a stream.

Example

Function CreateJson: IIOStreamSys;
Var
    NewJSON: IJsonObjectBuilder;
    Doc: IJsonDocument;
    MemStr: IMemoryStream;
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 stream
    Doc := New JsonDocument.Create;
    Doc.RootElement := NewJSON.Build;
    MemStr := New MemoryStream.Create;
    Doc.WriteToStream(MemStr);
    Return MemStr;
End Function CreateJson;

The specified function creates a new JSON structure with a set of elements. The function results in the stream, to which JSON structure is saved.

See also:

IJsonDocument