use flask.jsonify instead of custom json encode function