import json d = dict(age=132,name='张三') class Student(object): def __init__(self, name, age): self.name = name self.age = age pass student = Student('张三',20) s = json.dumps(student, default= lambda self: self.__dict__) s = json.loads(s, object_hook = lambda df: Student(df['name'], df['age'])) print(s)
Sign in to make a reply
Aspire