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 <C_CkJsonObject.h>
#include <C_CkStringTable.h>

void ChilkatSample(void)
    {
    HCkJsonObject json;
    HCkStringTable st;

    json = CkJsonObject_Create();
    CkJsonObject_putEmitCompact(json,FALSE);

    CkJsonObject_AppendString(json,"abc","123");

    st = CkStringTable_Create();
    CkStringTable_Append(st,"a");
    CkStringTable_Append(st,"b");
    CkStringTable_Append(st,"c");
    CkStringTable_Append(st,"d");

    CkJsonObject_AppendStringArray(json,"strArray",st);

    printf("%s\n",CkJsonObject_emit(json));

    // Output:

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


    CkJsonObject_Dispose(json);
    CkStringTable_Dispose(st);

    }