TypeError: Decimal type object is not a JSON serialization solution

The data type calculated when python connects to a database using select sum(a) from b is Decimal. But this format doesn’t fit the json format, so we can cast the data we get. Convert to an integer, and you’ll be able to fit the JSON format.

def get_cl_data():
    data = utils.get_conn()
    # data = json.dumps({"confirm": data[0], "suspect": data[1], "heal": data[2], "dead": data[3]})
    # print(data)
    return jsonify({"confirm": int(data[0]), "suspect": int(data[1]), "heal": int(data[2]), "dead": int(data[3])})

</ div>

Read More: