What is one of the pythonic ways to convert a string which has a built-in dictionary formatting into a dictionary? I have tried regex but it isn't quite there to be the right formatting .
string_dictable ="{""name"":""Andrew,Carnegie"",""short_name"":""And,Car"",
""YOB"":1835,""Citizen"":""Scottish""}"
All the extra quotation paddings seem to be the problem and so far I haven't been able to work around them.
My expected output is:
dicted_string ={"name":"Andrew, Carnegie","short_name":"And,Car","YOB":1835,"Citizen":"Scottish"}
I have also tried
ast.literal_eval (string_dictable)
to no avail.
EDIT: I haven't touched the original formatting and unfortunately, the original question cannot be clarified or modified. Thanks all for the contribution though. As I have said the regex solution got me this
{'{name': 'Andrew,Carnegie,short_name:And,Car,YOB:1835,Citizen:Scottish}'}
and it isn't exactly what I needed to do some work on.