IJsonObjectBuilder.AddObjectBuilder

Syntax

AddObjectBuilder(Property_: String; Value: IJsonObjectBuilder): IJsonObjectBuilder;

Parameters

Property_. Element name.

Value. Created JSON object.

Description

The AddObjectBuilder method adds an element with JSON object as a value.

Example

Sub UserProc;
Var
    NewJSON, SubJSON: IJsonObjectBuilder;
    Doc: IJsonDocument;
Begin
    // Create JSON structure
    NewJSON := New JsonObjectBuilder.Create;
    SubJSON := New JsonObjectBuilder.Create;
    SubJSON.AddInteger("price"100);
    SubJSON.AddDouble("weight"1);
    NewJSON.AddObjectBuilder("Product 1", SubJSON);
    SubJSON := New JsonObjectBuilder.Create;
    SubJSON.AddInteger("price"200);
    SubJSON.AddDouble("weight"1.2);
    NewJSON.AddObjectBuilder("Product 2", SubJSON);
    // Save
    Doc := New JsonDocument.Create;
    Doc.RootElement := NewJSON.Build;
    Doc.WriteToFile("d:\Work\Json\info.json");
End Sub UserProc;

The specified function creates a new JSON structure, to which elements with a set of child objects will be added. The structure will be saved to the specified file.

See also:

IJsonObjectBuilder