def to_objectid(objid): """字符对象转换成objectid """ if objid is None: return objid try: objid = ObjectId(objid) except: util_log.error('%s is invalid objectid' % objid) return None return objid
def to_objectid(objid): """字符对象转换成objectid """ if objid is None: return objid try: objid = ObjectId(objid) except: util_log.error("%s is invalid objectid" % objid) return None return objid
def to_float(value, default=None): try: return float(value) except ValueError as e: util_log.error(e)
def json_decode(data, **kwargs): try: return json.loads(data, **kwargs) except: util_log.error('Uncaught exception in json_decode', exc_info=True)
def json_encode(data, **kwargs): try: return json.dumps(data, **kwargs) except Exception as e: util_log.error("Uncaught exception in json_encode", exc_info=True)