conver string to dictionary
Gabriel Genellina
gagsl-py at yahoo.com.ar
Sun Feb 18 03:30:26 EST 2007
En Sun, 18 Feb 2007 03:44:47 -0300, mahdieh saeed <maheh_saied at yahoo.com>
escribió:
> Hi
> I want to convert string to dictionary .what is the best solution for
> this ?
> for example string is like this:
> '{"SalutationID":["primarykey",8388607,0,None],"CompanyID":[0,8388607,0,"index"],
> "SalutationName":["",255,0,None],"isDefault":["tinyint",1,1,None]}'
> and I want to convert this string to this dictionary:
> {"SalutationID":["primarykey",8388607,0,None],"CompanyID":[0,8388607,0,"index"],
> "SalutationName":["",255,0,None],"isDefault":["tinyint",1,1,None]}
> please help me what is the best solution(faster solution) for this?
The simplest way is to use eval(), but only do that if you can trust
absolutely the source. To be safe, you can use this recipe:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/364469
--
Gabriel Genellina
More information about the Python-list
mailing list