Implement JSON serialization for Gradient and GradientColor.