Here is a nice reference for reading/writing buffers on the W3Schools site.
For instance, if you just want to replace the 4-byte payload buffer with its 32-bit signed
big-endian integer value, try this:
msg.payload = msg.payload.readInt32BE();
return msg;