Sample code for 30+ languages & platforms
Objective-C

Get JSON Details from the Last REST Operation

See more REST Examples

Demonstrates Rest.GetLastJsonData, which copies operation-specific diagnostic or result information from the most recently completed method into a JsonObject. Many methods produce no JSON, in which case the object is empty.

Tip: Code to parse the returned JSON can be generated with Chilkat's online tool at https://tools.chilkat.io/jsonParse.

Background. Some Chilkat operations expose additional structured information as JSON. GetLastJsonData provides access to that information after an operation completes.

Chilkat Objective-C Downloads

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

BOOL success = NO;

CkoRest *rest = [[CkoRest alloc] init];
BOOL bTls = YES;
BOOL bAutoReconnect = YES;
success = [rest Connect: @"example.com" port: [NSNumber numberWithInt: 443] tls: bTls autoReconnect: bAutoReconnect];
if (success == NO) {
    NSLog(@"%@",rest.LastErrorText);
    return;
}

//  Copy operation-specific diagnostic or result information from the most recent method (here the
//  Connect call) into a JsonObject.  Many methods produce no JSON, in which case the object is empty.
CkoJsonObject *json = [[CkoJsonObject alloc] init];
[rest GetLastJsonData: json];

json.EmitCompact = NO;
NSString *jsonStr = [json Emit];
NSLog(@"%@",jsonStr);
//  JSON parsing code for this result can be generated at Chilkat's online tool:
//  https://tools.chilkat.io/jsonParse