0

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

@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

 {
  "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.

MADPED
  • 23
  • 7
  • why single line is important? – balderman Nov 09 '21 at 19:42
  • @balderman I don't know exactly I try to work with a code (html , jQuery , ajax) that I'm unfamiliar with them and I know when send response in a solid single line that code worked – MADPED Nov 09 '21 at 19:50
  • I don't think it has ANY importance.. – balderman Nov 09 '21 at 19:51
  • @balderman you are right, I test and don't work again may I look deeper in code and something is unusual is when send exactly this response but in ' '(string mode) that code worked – MADPED Nov 09 '21 at 20:27

1 Answers1

0

Are you running Flask in debug mode? Try setting JSONIFY_PRETTYPRINT_REGULAR environment variable to 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.

Oleg
  • 961
  • 8
  • 16