[英]How to return a json response in one line in flask?
I am coding a route in flask to send this response and I need to send this json response in a single solid line but when I send this json(because of length) send in multiple line我正在烧瓶中编写一条路由以发送此响应,我需要以单条实线发送此 json 响应,但是当我发送此 json(因为长度)时,以多行发送
@app.route("/dashboard", methods= ['GET','POST'])
def index():
.
.
.
response = {"iDisplayStart":1,"iDisplayLength":10,
"iTotalRecords":2,"iTotalDisplayRecords":2,"data":data_ne}
return jsonify(results)
when I send this json response return below当我发送这个 json 响应返回下面
{
"iDisplayStart": 1,
"iDisplayLength": 10,
"iTotalRecords": 2,
"iTotalDisplayRecords": 2,
"data": [
{data_ne}]}
but I want to be in single line like below但我想像下面这样单行
{"iDisplayStart":1,"iDisplayLength":10,"iTotalRecords":2,"iTotalDisplayRecords":2,"data":data_ne}
Is there any way to do this?有没有办法做到这一点? Thanks for your consideration.
感谢您的考虑。
Are you running Flask in debug mode?您是否在调试模式下运行 Flask? Try setting
JSONIFY_PRETTYPRINT_REGULAR
environment variable to false.尝试将
JSONIFY_PRETTYPRINT_REGULAR
环境变量设置为 false。 From the documentation :从文档:
The default output omits indents and spaces after separators.
默认输出省略分隔符后的缩进和空格。 In debug mode or if JSONIFY_PRETTYPRINT_REGULAR is True, the output will be formatted to be easier to read.
在调试模式下或如果 JSONIFY_PRETTYPRINT_REGULAR 为 True,输出将被格式化为更易于阅读。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.