Sample code for 30+ languages & platforms
Unicode C++

JSON AppendObject2 Example

Demonstrates the AppendObject2 function.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkJsonObjectW.h>

void ChilkatSample(void)
    {
    CkJsonObjectW json;
    json.Load(L"{ \"name\": \"John\", \"marbles\": 100 }");

    //  Append an empty object named "addr"
    CkJsonObjectW jObj;
    json.AppendObject2(L"addr",jObj);

    wprintf(L"%s\n",json.emit());
    //  Expected output is:   {"name":"John","marbles":100,"addr":{}}

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

    wprintf(L"%s\n",json.emit());
    //  Expected output is:  {"name":"John","marbles":100,"addr":{"street":"1200 Elm St.","city":"Springfield","zip":60606}}
    }