Sample code for 30+ languages & platforms
Tcl

Example: JsonObject.NewArrayOf method

See more JSON Examples

Demonstrates the NewArrayOf method.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set big_cats "[\"lion\",\"tiger\",\"leopard\",\"jaguar\",\"cheetah\",\"snow leopard\",\"clouded leopard\",\"cougar\",\"puma\",\"panther\"]"

set json [new_CkJsonObject]

CkJsonObject_UpdateString $json "test" "abc"

set success [CkJsonObject_NewArrayOf $json "big_cats" $big_cats]
if {$success == 0} then {
    puts [CkJsonObject_lastErrorText $json]
    delete_CkJsonObject $json
    exit
}

CkJsonObject_put_EmitCompact $json 0
puts [CkJsonObject_emit $json]

# Result:

# {
#   "test": "abc",
#   "big_cats": [
#     "lion",
#     "tiger",
#     "leopard",
#     "jaguar",
#     "cheetah",
#     "snow leopard",
#     "clouded leopard",
#     "cougar",
#     "puma",
#     "panther"
#   ]
# }

delete_CkJsonObject $json