Avatar ·

Typeerror: Object of type is not json serializable

📁 Advanced Python Topics

I am trying to record a Person class object like this:

 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()

I get an error:

 TypeError: Object of type Person is not JSON serializable