Sample code for 30+ languages & platforms
Objective-C

JSON PathPrefix Example

Demonstrates the JSON object's PathPrefix property.

Chilkat Objective-C Downloads

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

BOOL success = NO;

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

json.PathPrefix = @"company.billing.";

[json UpdateString: @"company_name" value: @"TechNova Solutions Inc."];
[json UpdateString: @"address_line_1" value: @"123 Innovation Drive"];
[json UpdateString: @"address_line_2" value: @"Suite 450"];
[json UpdateString: @"city" value: @"Seattle"];
[json UpdateString: @"state_province" value: @"WA"];
[json UpdateString: @"postal_code" value: @"98101"];
[json UpdateString: @"country" value: @"USA"];

json.EmitCompact = NO;

NSLog(@"%@",[json Emit]);

//  Result:

//  {
//    "company": {
//      "billing": {
//        "company_name": "TechNova Solutions Inc.",
//        "address_line_1": "123 Innovation Drive",
//        "address_line_2": "Suite 450",
//        "city": "Seattle",
//        "state_province": "WA",
//        "postal_code": "98101",
//        "country": "USA"
//      }
//    }
//  }

NSString *city = [json StringOf: @"city"];
NSLog(@"%@%@",@"city = ",city);