python - Using json.dumps(string) to dump a string -


i want put string json.dumps()

string = "{data}"  print json.dumps(string) 

and get:

"{data}" instead of: {data}

how can string without quotes?

method replace:

json.dumps(string.replace('"', '') 

or strip:

json.dumps(string.strip('"') 

does not work.

you don't dump a string to a string.

d = {"foo": "bar"} j = json.dumps(d) print(j) 

output:

{"foo": "bar"} 

it makes no sense use string argument of json.dumps expecting dictionary or list/tuple argument.

serialize obj json formatted str using conversion table.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -