Sample code for 30+ languages & platforms
C++

Create JSON Array of Strings

See more JSON Examples

Demonstrates how to create a JSON array of strings.

Chilkat C++ Downloads

C++
#include <CkJsonArray.h>

void ChilkatSample(void)
    {
    // The goal of this example is to produce this:

    // [
    //   "tag1",
    //   "tag2",
    //   "tag3"
    // ]

    CkJsonArray jarr;
    jarr.AddStringAt(-1,"tag1");
    jarr.AddStringAt(-1,"tag2");
    jarr.AddStringAt(-1,"tag3");

    jarr.put_EmitCompact(false);
    std::cout << jarr.emit() << "\r\n";
    }