一个自定义的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__)
posted @ 2011-11-29 13:53  $walker  阅读(326)  评论(0编辑  收藏  举报