sensu-grid icon indicating copy to clipboard operation
sensu-grid copied to clipboard

replacing json.dumps with flask jsonify helper wrapper

Open daghan opened this issue 5 years ago • 1 comments

Hi Alex,

We have a free program analysis tool for Python based web projects, called Bento. While we were scanning GitHub projects for issues, your project triggered a warning for using json.dumps() instead of flask jsonify().

According to this Stackoverflow article (https://stackoverflow.com/questions/7907596/json-dumps-vs-flask-jsonify), the jsonify() function in flask returns a flask.Response() object that already has the appropriate content-type header 'application/json' for use with json responses. It also has support for handling multiple args / kwargs, including lists. Hopefully, you'll find this PR useful.

Bento flagged 2 other issues related to unsafe loading of yaml files and possible Python3 compatibility problem in griddata.py:149, but I didn't want to touch those issues in this PR. If you are interested, feel free download and give Bento a try (https://bento.dev).

daghan avatar Jan 02 '20 19:01 daghan

Thanks @daghan !

I haven't had time to test this, did you run it using jsonify()?

alex-leonhardt avatar Jan 11 '20 16:01 alex-leonhardt