我正在燒瓶中撰寫一條路由來發送這個回應,我需要在一條實線上發送這個 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)
當我發送這個 json 回應回傳下面
{
"iDisplayStart": 1,
"iDisplayLength": 10,
"iTotalRecords": 2,
"iTotalDisplayRecords": 2,
"data": [
{data_ne}]}
但我想像下面這樣單行
{"iDisplayStart":1,"iDisplayLength":10,"iTotalRecords":2,"iTotalDisplayRecords":2,"data":data_ne}
有沒有辦法做到這一點?感謝您的考慮。
uj5u.com熱心網友回復:
您是否在除錯模式下運行 Flask?嘗試將JSONIFY_PRETTYPRINT_REGULAR環境變數設定為 false。從檔案:
默認輸出省略分隔符后的縮進和空格。在除錯模式下或如果 JSONIFY_PRETTYPRINT_REGULAR 為 True,輸出將被格式化為更易于閱讀。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/354721.html
