(Objective-C) Example: JsonObject.NewArrayOf method
Demonstrates the NewArrayOf method.Note: This example requires Chilkat v11.4.0 or greater.
#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"
// ]
// }
|