Sample code for 30+ languages & platforms
Objective-C

JSON UpdateString

See more JSON Examples

Demonstrates the JSON object's UpdateString method.

Note: The UpdateString method was introduced in Chilkat v9.5.0.63

Chilkat Objective-C Downloads

Objective-C
#import <CkoJsonObject.h>

//  This example requires Chilkat v9.5.0.63 or greater.

CkoJsonObject *json = [[CkoJsonObject alloc] init];
json.EmitCompact = NO;

//  The UpdateString method updates or adds a string member.
//  It also auto-creates the objects and/or arrays that
//  are missing.  For example:
[json UpdateString: @"test.abc[0].xyz" value: @"Chicago Cubs"];

//  The JSON now contains:
NSLog(@"%@",[json Emit]);

//  {
//    "test": {
//      "abc": [
//        {
//          "xyz": "Chicago Cubs"
//        }
//      ]
//    }

[json UpdateString: @"test.abc[0].xyz" value: @"Chicago Cubs are going to win the World Series!"];
NSLog(@"%@",[json Emit]);

//  {
//    "test": {
//      "abc": [
//        {
//          "xyz": "Chicago Cubs are going to win the World Series!"
//        }
//      ]
//    }