// Serialize the Ping object to a byte array ByteArrayOutputStreambaos=newByteArrayOutputStream(); ObjectOutputStreamoos=newObjectOutputStream(baos); oos.writeObject(ping);
// Encode the byte array to Base64 Stringpayload=newString(Base64.getEncoder().encode(baos.toByteArray())); System.out.println("Payload: " + payload); } } //Payload: rO0ABXNyABVjb20uZXhhbXBsZS5kZW1vLlBpbmcAAAAAAAAAAQIAA0wABGFyZzF0ABJMamF2YS9sYW5nL1N0cmluZztMAARhcmcycQB+AAFMAAdjb21tYW5kcQB+AAF4cHQAAi1jdABfYmFzaCAtYyAne2VjaG8sWW1GemFDQXRhU0ErSmlBdlpHVjJMM1JqY0M4eExqRXlMakkxTVM0Mk1pODBOVFkzSURBK0pqRT19fHtiYXNlNjQsLWR9fHtiYXNoLC1pfSd0AARiYXNo