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.
@app.route('/c1')
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:
- [Solved] TypeError: Object of type ‘bytes’ is not JSON serializable
- [How to Solve] Python TypeError: ‘int‘ object is not subscriptable
- Python scatter chart error: TypeError: object of type ‘NoneType’ has no len()
- [Solved] python-sutime Error: the JSON object must be str, bytes or bytearray, not ‘java.lang.String‘
- Django Issues: TypeError: “Settings” object is irreversible
- [Solved] Python serializate error: NameError: name ‘JSON’ is not defined
- Python PIP TypeError: expected str, bytes or os.PathLike object, not int
- Typeerror in Python regular expression: expected string or bytes like object
- Python Pandas Typeerror: invalid type comparison
- Python parsing JSON Error: NameError: name ‘false’ is not defined
- [Solved] TypeError: unsupported operand type(s) for /: ‘str‘ and ‘int‘
- Python TypeError: Unrecognized value type: <class ‘str‘>dateutil.parser._parser.ParserError: Unknow
- Python error: ‘int’ object is not callable
- ‘coroutine‘ object is not iterable [How to Solve]
- [Solved] YOLOv5 Model training error: TypeError: new(): invalid data type ‘str’
- VScode debug error: configured debug type ‘Python’ is not supported
- [Solved] Simple jwt Error: AttributeError: type object ‘BlacklistedToken‘ has no attribute ‘objects
- [Solved] TypeError: not all arguments converted during string formatting
- [Solved] error: when using the property decorator in Python, an error occurs: typeerror: descriptor ‘setter’ requires a ‘property’ object but
- Keras import a custom metric model error: unknown metric function: Please ensure this object is passed to`custom_object‘