<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def serialize(obj):
 """Serialize the given object into JSON. Args: obj: the object to be serialized. Returns: (str):
 JSON representation of the given object. """

    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)