Sample code for 30+ languages & platforms
Java

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 Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.JsonObject;
import com.chilkatsoft.chilkat2.StringTable;

public class ChilkatExample {

    public static void main(String[] args) {
        JsonObject json = new JsonObject();
        json.setEmitCompact(false);

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

        StringTable st = new StringTable();
        st.append("a");
        st.append("b");
        st.append("c");
        st.append("d");

        json.appendStringArray("strArray", st);

        System.out.println(json.emit());

        // Output:

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