Sample code for 30+ languages & platforms
Swift

Create JSON Array of Strings

See more JSON Examples

Demonstrates how to create a JSON array of strings.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    // The goal of this example is to produce this:

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

    let jarr = CkoJsonArray()!
    jarr.addString(at: -1, value: "tag1")
    jarr.addString(at: -1, value: "tag2")
    jarr.addString(at: -1, value: "tag3")

    jarr.emitCompact = false
    print("\(jarr.emit()!)")

}