1

I'm using jsonify function to return in Flask:

 return jsonify(results = results_arr)

and I'm getting output like this:

{"results":[{"image":"103901.jpg","score":"2.51322851309"},{"image":"103401.jpg","score":"5.93861453397"}]}

I tried to do this in django by:

return json.dumps(results = results_arr)

But it doesn't work like on jsonify on Flask, can someone help me with this?

davidism
  • 121,510
  • 29
  • 395
  • 339
BigTrunk98
  • 109
  • 1
  • 7
  • In Flask `return jsonify(...)` returns an HTTP response but `return json.dumps(...)` does not do the same. You need to use `return JsonResponse({'results': results_arr})` – ettanany Dec 13 '16 at 16:50
  • @ettanany Thank you, it solved my problem! – BigTrunk98 Dec 13 '16 at 16:52

0 Answers0