import json
# 序列化对象为字符串
def objectToJsonStr(mObject: object):
return json.dumps(mObject.__dict__, ensure_ascii=False)
# 序列化嵌套对象为字符串
def nestedObjectToJsonStr(mObject: object):
return json.dumps(mObject.__dict__, default=lambda o: o.__dict__, ensure_ascii=False)
网友评论