Sample code for 30+ languages & platforms
Delphi ActiveX

JSON AppendObject2 Example

Demonstrates the AppendObject2 function.

Chilkat Delphi ActiveX Downloads

Delphi ActiveX
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;

...

procedure TForm1.Button1Click(Sender: TObject);
var
json: TChilkatJsonObject;
jObj: TChilkatJsonObject;

begin
json := TChilkatJsonObject.Create(Self);
json.Load('{ "name": "John", "marbles": 100 }');

// Append an empty object named "addr"
jObj := TChilkatJsonObject.Create(Self);
json.AppendObject2('addr',jObj.ControlInterface);

Memo1.Lines.Add(json.Emit());
// Expected output is:   {"name":"John","marbles":100,"addr":{}}

// Add members to the object.
jObj.AppendString('street','1200 Elm St.');
jObj.AppendString('city','Springfield');
jObj.AppendInt('zip',60606);

Memo1.Lines.Add(json.Emit());
// Expected output is:  {"name":"John","marbles":100,"addr":{"street":"1200 Elm St.","city":"Springfield","zip":60606}}
end;