Sample code for 30+ languages & platforms
PowerBuilder

Get the JWS Payload as a String

See more JSON Web Signatures (JWS) Examples

Demonstrates Jws.GetPayload, which returns the payload of a loaded JWS as text, decoded using the given charset.

Background. In practice, validate the signature before trusting the payload. Getting the payload retrieves the signed content.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Jws
string ls_JwsCompact
string ls_Payload

li_Success = 0

loo_Jws = create oleobject
li_rc = loo_Jws.ConnectToNewObject("Chilkat.Jws")
if li_rc < 0 then
    destroy loo_Jws
    MessageBox("Error","Connecting to COM object failed")
    return
end if

//  Load the JWS compact serialization.
ls_JwsCompact = "eyJhbGciOiJIUzI1NiJ9.VGhpcyBpcyB0aGUgY29udGVudCB0byBzaWduLg.<signature>"
li_Success = loo_Jws.LoadJws(ls_JwsCompact)
if li_Success = 0 then
    Write-Debug loo_Jws.LastErrorText
    destroy loo_Jws
    return
end if

//  Return the JWS payload as text, decoded using the given charset.
ls_Payload = loo_Jws.GetPayload("utf-8")
if loo_Jws.LastMethodSuccess = 0 then
    Write-Debug loo_Jws.LastErrorText
    destroy loo_Jws
    return
end if

Write-Debug ls_Payload


destroy loo_Jws