Sample code for 30+ languages & platforms
JavaScript

Example: JsonObject.NewArrayOf method

See more JSON Examples

Demonstrates the NewArrayOf method.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

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

var json = new CkJsonObject();

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

success = json.NewArrayOf("big_cats",big_cats);
if (success == false) {
    console.log(json.LastErrorText);
    return;
}

json.EmitCompact = false;
console.log(json.Emit());

// Result:

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