code: def serialize(self, value, **kwargs):
          
          kwargs.update({'include_class': kwargs.get('include_class', True)})
          if self.serializer is not None:
              return self.serializer(value, **kwargs)
          if value is None:
              return None
          if isinstance(value, HasProperties):
              return value.serialize(**kwargs)
          return self.to_json(value, **kwargs)
docs: Serialize instance to JSON
  
          If the value is a HasProperties instance, it is serialized with
          the include_class argument passed along. Otherwise, to_json is
          called.