Objective-C
Objective-C
Copy JSON Object from one JSON Array to Another
See more JSON Examples
Demonstrates how to copy an object in a JSON array to another JSON array.Chilkat Objective-C Downloads
#import <CkoJsonArray.h>
#import <NSString.h>
#import <CkoJsonObject.h>
CkoJsonArray *arr1 = [[CkoJsonArray alloc] init];
CkoJsonArray *arr2 = [[CkoJsonArray alloc] init];
NSString *s = @"[{\"a\":1}, {\"b\":2}, {\"c\":3}]";
NSString *sEmpty = @"[]";
[arr1 Load: s];
[arr2 Load: sEmpty];
CkoJsonObject *jObj = [[CkoJsonObject alloc] init];
[arr1 ObjectAt2: [NSNumber numberWithInt: 1] jsonObj: jObj];
[arr2 AddObjectCopyAt: [NSNumber numberWithInt: -1] jsonObj: jObj];
NSLog(@"%@",[arr2 Emit]);
// output is: [{"b":2}]