Sample code for 30+ languages & platforms
C++

JSON Append String Array

See more JSON Examples

Demonstrates how to append an array of strings from a string table object.

Note: This example uses the AppendStringTable method, which was introduced in Chilkat v9.5.0.67

Chilkat C++ Downloads

C++
#include <CkJsonObject.h>
#include <CkStringTable.h>

void ChilkatSample(void)
    {
    CkJsonObject json;
    json.put_EmitCompact(false);

    json.AppendString("abc","123");

    CkStringTable st;
    st.Append("a");
    st.Append("b");
    st.Append("c");
    st.Append("d");

    json.AppendStringArray("strArray",st);

    std::cout << json.emit() << "\r\n";

    //  Output:

    //  	{
    //  	  "abc": "123",
    //  	  "strArray": [
    //  	    "a",
    //  	    "b",
    //  	    "c",
    //  	    "d"
    //  	  ]
    //  	}
    }