Swift
Swift
Example: JsonObject.NewArrayOf method
See more JSON Examples
Demonstrates theNewArrayOf method.
Chilkat Swift Downloads
func chilkatTest() {
var success: Bool = false
var big_cats: String? = "[\"lion\",\"tiger\",\"leopard\",\"jaguar\",\"cheetah\",\"snow leopard\",\"clouded leopard\",\"cougar\",\"puma\",\"panther\"]"
let json = CkoJsonObject()!
json.updateString(jsonPath: "test", value: "abc")
success = json.newArray(of: "big_cats", jArr: big_cats)
if success == false {
print("\(json.lastErrorText!)")
return
}
json.emitCompact = false
print("\(json.emit()!)")
// Result:
// {
// "test": "abc",
// "big_cats": [
// "lion",
// "tiger",
// "leopard",
// "jaguar",
// "cheetah",
// "snow leopard",
// "clouded leopard",
// "cougar",
// "puma",
// "panther"
// ]
// }
}