Avatar ·

Typeerror: Object of type is not json serializable

📁 Python

Ich versuche, ein Person-Klassenobjekt wie folgt zu speichern:

 def postusertojson(user):
    filename = str(user.fullname) + "" + str(user.id)
    file = open(Pathusers + filename + ".json", "w", encoding="utf-8")
    json.dump(user, file, ensure_ascii=false)
    file.close()

Ich erhalte einen Fehler:

TypeError: Object of type Person is not JSON serializable