IJsonObjectBuilder.AddArray

Syntax

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

AddArray(Property_: String; Value: Array): IPrognoz.Platform.Interop.ForeSystem.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

Add links to the ForeSystem (for the Fore.NET example) system assembly.

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.Root := NewJSON.Build;
    Doc.WriteToFile(
"d:\Work\Json\testfile.json");
End Sub UserProc;

Imports Prognoz.Platform.Interop.ForeSystem;

Sub UserProc();
Var
    NewJSON: JsonObjectBuilder = 
New JsonObjectBuilderClass();
    VarArray: Array;
    JsonArray: JsonArrayBuilder = 
New JsonArrayBuilderClass();
    Doc: IJsonDocument = 
New JsonDocument();
Begin
    
// First array
    VarArray := New Object[2];
    VarArray[
0] := Integer.MaxValue;
    VarArray[
1] := Double.MaxValue;
    NewJSON.AddArray(
"First Array", VarArray);
    
// Second array
    JsonArray.AddInteger(Integer.MaxValue);
    JsonArray.AddDouble(Double.MaxValue);
    NewJSON.AddArrayBuilder(
"Two Array", JsonArray);
    
// Save obtained JSON
    Doc.Root := NewJSON.Build();
    Doc.WriteToFile(
"d:\Work\Json\testfile.json", JsonFormatOptions.jfoDefault);
End Sub;

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