add ToJson method to the base class template