Avatar ·

TypeError: Object of type is not JSON serializable

📁 python

Estoy intentando guardar un objeto de la clase Person de esta manera:


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

Obtengo un error:


TypeError: Object of type