I am currently working on a python client to talk with a webservice I am developing. Currently I am running into a issue where my webservice is expecting a very specific formated request but when I send my request thru json.dumps its adding in extra \ that causes my webservice to fail out.
Here is a example of the problem just typing some code into python:
>>> import json
>>> body = {}
>>> body['hosts'] = '["cso22"]'
>>> print json.dumps(body)
{"hosts": "[\"CSO22\"]"}
So now instead of body[‘hosts’] equaling ‘[“CSO22″]’ it equals ‘[\\”CSO22\\”]’ which isn’t what my webservice is expecting so it returns back http error 400. Is there a way to change this behavor so that json.dumps will return back the value i need it to?
Remove the single quotes around
'["CSO22"]'to create an array: