Node.js
Node.js
Example: JsonObject.NewArrayOf method
See more JSON Examples
Demonstrates theNewArrayOf method.
Chilkat Node.js Downloads
NODEJS_PRELUDE
function chilkatExample() {
var success = false;
var big_cats = "[\"lion\",\"tiger\",\"leopard\",\"jaguar\",\"cheetah\",\"snow leopard\",\"clouded leopard\",\"cougar\",\"puma\",\"panther\"]";
var json = new chilkat.JsonObject();
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"
// ]
// }
}
chilkatExample();