Sample code for 30+ languages & platforms
CkPython

Example: JsonObject.NewArrayOf method

See more JSON Examples

Demonstrates the NewArrayOf method.

Chilkat CkPython Downloads

CkPython
import sys
import chilkat

success = False

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

json = chilkat.CkJsonObject()

json.UpdateString("test","abc")

success = json.NewArrayOf("big_cats",big_cats)
if (success == False):
    print(json.lastErrorText())
    sys.exit()

json.put_EmitCompact(False)
print(json.emit())

# Result:

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