using simplejson.dumps to encode a dictionary to json

MRAB python at mrabarnett.plus.com
Tue Mar 15 16:19:33 EDT 2011


On 15/03/2011 19:40, Aaron wrote:
> Hi there,
>
> I am attempting to use simplejson.dumps to convert a dictionary to a json encoded string.
>
> For some reason this doesn't work - it would be awesome if someone could give me a clue as to why.
>
> loginreq = {"username":username, "password":password, "productType":"CFD_Demo"}
> authreq_data = {"req":loginreq}
> authreq_data = simplejson.dumps(authreq_data)
>
> A
>
> #The dictionary contains a dictionary

Which version of Python? Versions of Python since 2.6 come with a
"json" module.



More information about the Python-list mailing list