Sample code for 30+ languages & platforms
Node.js

Example: JsonObject.NewArrayOf method

See more JSON Examples

Demonstrates the NewArrayOf method.

Chilkat Node.js Downloads

Node.js
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();