Added an abstraction for serializing a payload.