IJsonObjectBuilder.AddArray

Syntax

AddArray(Property_: String; Value: Array): IJsonObjectBuilder;

Parameters

Property_. Element name.

Value. Array that will be used as an element value.

Description

The AddArray method adds an element with a values array.

Example

Sub UserProc;
Var
    NewJSON: IJsonObjectBuilder;
    VarArray: Array;
    JsonArray: IJsonArrayBuilder;
    Doc: IJsonDocument;
Begin
    NewJSON := New JsonObjectBuilder.Create;
    // First array
    VarArray := New Variant[2];
    VarArray[0] := Integer.MaxValue;
    VarArray[1] := Double.MaxValue;
    NewJSON.AddArray("First Array", VarArray);
    // Second array
    JsonArray := New JsonArrayBuilder.Create;
    JsonArray.AddInteger(Integer.MaxValue);
    JsonArray.AddDouble(Double.MaxValue);
    NewJSON.AddArrayBuilder("Two Array", JsonArray);
    // Save obtained JSON
    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 will be created. Two elements, which values are elements arrays, will be added in various ways to the structure. The structure will be saved to the specified file.

See also:

IJsonObjectBuilder