一个自定义的json序列化对象的方法

import json
def json_encode(o):
    t = type(o)
    if t is list or t is tuple:
        return json.dumps([oo.__dict__ for oo in o])
    else:
        return json.dumps(o.__dict__)
原文地址:https://www.cnblogs.com/walkerwang/p/2267531.html