Move JSON serialization to the Task interface and class