Make the JSON API use Flask's jsonify function, and keep to JSON security standards.

Flask's jsonify function is easier to deal with, plus it sets the content-type to application/json and avoid escaping quotes and slashes as was happening with the simple returning of json.dumps.

Check the comment I added for more info about JSON security.