def METHOD_NAME (self, o):
    if  isinstance (o, ObjectId):
        return str (o)
    if  isinstance (o, datetime.datetime):
        seconds  = time.mktime (o.timetuple ())
        seconds += (o.microsecond / 1000000.0)
        return seconds
    return json.JSONEncoder.METHOD_NAME (self, o)