Go
Go
Example: JsonObject.NewArrayOf method
See more JSON Examples
Demonstrates theNewArrayOf method.
Chilkat Go Downloads
success := false
big_cats := "[\"lion\",\"tiger\",\"leopard\",\"jaguar\",\"cheetah\",\"snow leopard\",\"clouded leopard\",\"cougar\",\"puma\",\"panther\"]"
json := chilkat.NewJsonObject()
json.UpdateString("test","abc")
success = json.NewArrayOf("big_cats",big_cats)
if success == false {
fmt.Println(json.LastErrorText())
json.DisposeJsonObject()
return
}
json.SetEmitCompact(false)
fmt.Println(*json.Emit())
// Result:
// {
// "test": "abc",
// "big_cats": [
// "lion",
// "tiger",
// "leopard",
// "jaguar",
// "cheetah",
// "snow leopard",
// "clouded leopard",
// "cougar",
// "puma",
// "panther"
// ]
// }
json.DisposeJsonObject()