Serialize object