PowerBuilder
PowerBuilder
Get JSON Details from the Last Operation
See more MIME Examples
Demonstrates GetLastJsonData, which copies structured details from the most recent operation into a JsonObject when such details are available. Many operations produce no JSON data, in which case the object is empty or minimal.
The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
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 extra diagnostic or result information as JSON. GetLastJsonData provides access to that information after the operation completes.
Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Mime
string ls_PfxPassword
oleobject loo_Json
string ls_JsonStr
li_Success = 0
loo_Mime = create oleobject
li_rc = loo_Mime.ConnectToNewObject("Chilkat.Mime")
if li_rc < 0 then
destroy loo_Mime
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Mime.LoadMimeFile("qa_data/encrypted.eml")
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
// Some operations produce structured JSON details. After an operation, copy those details into a
// JsonObject with GetLastJsonData. Many methods produce no JSON, in which case the object is
// little or empty.
ls_PfxPassword = "myPfxPassword"
li_Success = loo_Mime.AddPfxSourceFile("qa_data/recipient.pfx",ls_PfxPassword)
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
li_Success = loo_Mime.Decrypt()
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
loo_Mime.GetLastJsonData(loo_Json)
loo_Json.EmitCompact = 0
ls_JsonStr = loo_Json.Emit()
Write-Debug ls_JsonStr
destroy loo_Mime
destroy loo_Json