Sample code for 30+ languages & platforms
Objective-C

Example: JsonObject.NewArrayOf method

See more JSON Examples

Demonstrates the NewArrayOf method.

Chilkat Objective-C Downloads

Objective-C
#import <NSString.h>
#import <CkoJsonObject.h>

BOOL success = NO;

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

CkoJsonObject *json = [[CkoJsonObject alloc] init];

[json UpdateString: @"test" value: @"abc"];

success = [json NewArrayOf: @"big_cats" jArr: big_cats];
if (success == NO) {
    NSLog(@"%@",json.LastErrorText);
    return;
}

json.EmitCompact = NO;
NSLog(@"%@",[json Emit]);

//  Result:

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