Sample code for 30+ languages & platforms
Perl

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 Perl Downloads

Chilkat2 Perl
use strict;
use warnings;
use Chilkat2;

my $rest = Chilkat2::Rest->new;
my $bTls = 1;
my $bAutoReconnect = 1;
my $success = $rest->Connect('example.com', 443, $bTls, $bAutoReconnect);
if (!$success) {
    print $rest->LastErrorText, "\n";
    exit;
}

# 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.
my $json = Chilkat2::JsonObject->new;
$rest->GetLastJsonData($json);

$json->EmitCompact(0);
my $jsonStr = $json->Emit();
print $jsonStr, "\n";
# JSON parsing code for this result can be generated at Chilkat's online tool:
# https://tools.chilkat.io/jsonParse