How can I return an response (lets say an array) to the client with a name assign to it form a python script.
echo '{"jsonValidateReturn":'.json_encode($arrayToJs).'}';
in this scenario it returns an array with the name(jsonValidateReturn) assign to it also this can be accessed by jsonValidateReturn[1],so I want to do the same using a python script.
I tried it once but it didn't go well
array_to_js = [vld_id, vld_error, False]
array_to_js[2] = False
jsonValidateReturn = simplejson.dumps(array_to_js)
return HttpResponse(jsonValidateReturn, mimetype='application/json')
Thanks.
Try this for the last two lines:
jsonValidateReturn = simplejson.dumps({'jsonValidateReturn': array_to_js})
return HttpResponse(jsonValidateReturn, mimetype='application/json')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.