Chilkat2-Python
Chilkat2-Python
Example: JsonObject.NewArrayOf method
See more JSON Examples
Demonstrates theNewArrayOf method.
Chilkat Chilkat2-Python Downloads
import sys
import chilkat2
success = False
big_cats = "[\"lion\",\"tiger\",\"leopard\",\"jaguar\",\"cheetah\",\"snow leopard\",\"clouded leopard\",\"cougar\",\"puma\",\"panther\"]"
json = chilkat2.JsonObject()
json.UpdateString("test","abc")
success = json.NewArrayOf("big_cats",big_cats)
if (success == False):
print(json.LastErrorText)
sys.exit()
json.EmitCompact = False
print(json.Emit())
# Result:
# {
# "test": "abc",
# "big_cats": [
# "lion",
# "tiger",
# "leopard",
# "jaguar",
# "cheetah",
# "snow leopard",
# "clouded leopard",
# "cougar",
# "puma",
# "panther"
# ]
# }