Sample code for 30+ languages & platforms
Delphi DLL

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 Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
jws: HCkJws;
jwsCompact: PWideChar;
payload: PWideChar;

begin
success := False;

jws := CkJws_Create();

//  Load the JWS compact serialization.
jwsCompact := 'eyJhbGciOiJIUzI1NiJ9.VGhpcyBpcyB0aGUgY29udGVudCB0byBzaWduLg.<signature>';
success := CkJws_LoadJws(jws,jwsCompact);
if (success = False) then
  begin
    Memo1.Lines.Add(CkJws__lastErrorText(jws));
    Exit;
  end;

//  Return the JWS payload as text, decoded using the given charset.
payload := CkJws__getPayload(jws,'utf-8');
if (CkJws_getLastMethodSuccess(jws) = False) then
  begin
    Memo1.Lines.Add(CkJws__lastErrorText(jws));
    Exit;
  end;
Memo1.Lines.Add(payload);

CkJws_Dispose(jws);