On Tue, Mar 15, 2011 at 12:56 PM, Aaron <aaron.jerl...@gmail.com> wrote:
> If I print authreq_data to screen  I get
>
> {"req": {"username": "######", "password": "#####", "productType": 
> "CFD_Demo"}}
>
> Essentially I want the inner brackets to be  [ ] instead of {} but 
> alternating on each level so it would be:
>
> {"req": [{"username": "######", "password": "#####", "productType": 
> "CFD_Demo"}]}
>
> as per usual json.

I don't think there's a "usual JSON", but anyway, if you want a list,
then just use one:

from json import dumps
loginreq = {"username":username, "password":password, "productType":"CFD_Demo"}
authreq_data = {"req":[loginreq]} # note brackets
authreq_data = dumps(authreq_data)

>>> print(authreq_data)
{"req": [{"username": "USER", "password": "PASS", "productType": "CFD_Demo"}]}

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to