code: def serialize(obj):
      
      LOGGER.debug('serialize(%s)', obj)
  
      if isinstance(obj, datetime.date):
          return simplejson.dumps(obj, default=encoders.as_date)
  
      elif hasattr(obj, '__dict__'):
          return simplejson.dumps(obj, default=encoders.as_object)
  
      return simplejson.dumps(obj)
docs: Serialize the given object into JSON.
  
      Args:
          obj: the object to be serialized.
  
      Returns:
          (str): JSON representation of the given object.