template for getting serialize method from parameter type