Python | How to send a JSON response with name assign to it

Posted by MMRUser on Stack Overflow See other posts from Stack Overflow or by MMRUser
Published on 2010-03-13T06:12:09Z Indexed on 2010/03/13 6:15 UTC
Read the original article Hit count: 170

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about JSON

Related posts about python