I know this question sounds very naive but I am stuck with it. I am using jquery autocomplete and it turns out that it needs ["data1", "data2"] form of list.
I am getting data from a json file and
data = json.load(fobj)['content']
data = [str(data[d]['name']) for d in data.keys()]
['some text', 'some other '....]
but I specifically want a double quoted string in list. I have tried repr(str(data)) but in it gives "'some text'" and then "'some text'".strip("'") but again this returns a single quoted string.
To get the work done i am doing
data = [str(data[d]['name'] + "'") for d in data.keys()]
and later process the "'" at the end of string but this is not the right way.
Is there any way with which i can force str() to return double quoted string something like str(data, quote='"').
jQuery means JavaScript. JavaScript literals means JSON. Just re-encode.
>>> json.dumps(['foo', '''bar'''])
'["foo", "bar"]'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With