(Java) JSON Append String Array
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
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
CkJsonObject json = new CkJsonObject();
json.put_EmitCompact(false);
json.AppendString("abc","123");
CkStringTable st = new CkStringTable();
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"
// ]
// }
}
}
|