Sample code for 30+ languages & platforms
Tcl

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

Tcl

load ./chilkat.dll

set success 0

set rest [new_CkRest]

set bTls 1
set bAutoReconnect 1
set success [CkRest_Connect $rest "example.com" 443 $bTls $bAutoReconnect]
if {$success == 0} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    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.
set json [new_CkJsonObject]

CkRest_GetLastJsonData $rest $json

CkJsonObject_put_EmitCompact $json 0
set jsonStr [CkJsonObject_emit $json]
puts "$jsonStr"
#  JSON parsing code for this result can be generated at Chilkat's online tool:
#  https://tools.chilkat.io/jsonParse

delete_CkRest $rest
delete_CkJsonObject $json