Sample code for 30+ languages & platforms
Go

Example: JsonObject.NewArrayOf method

See more JSON Examples

Demonstrates the NewArrayOf method.

Chilkat Go Downloads

Go
    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()