Ruby
Ruby
Example: JsonObject.NewArrayOf method
See more JSON Examples
Demonstrates theNewArrayOf method.
Chilkat Ruby Downloads
require 'chilkat'
success = false
big_cats = "[\"lion\",\"tiger\",\"leopard\",\"jaguar\",\"cheetah\",\"snow leopard\",\"clouded leopard\",\"cougar\",\"puma\",\"panther\"]"
json = Chilkat::CkJsonObject.new()
json.UpdateString("test","abc")
success = json.NewArrayOf("big_cats",big_cats)
if (success == false)
print json.lastErrorText() + "\n";
exit
end
json.put_EmitCompact(false)
print json.emit() + "\n";
# Result:
# {
# "test": "abc",
# "big_cats": [
# "lion",
# "tiger",
# "leopard",
# "jaguar",
# "cheetah",
# "snow leopard",
# "clouded leopard",
# "cougar",
# "puma",
# "panther"
# ]
# }