I'm using python to do a sql query that returns the result below:
print i
(123.0, 460654.05)
(234.0, 292016.43)
(1231.0, 271915.11)
(234.0, 189367.59)
(1.0, 117566.06)
(2.0, 100600.76000000001)
(3.0, 90443.32)
(4.0, 84218.40000000001)
(5.0, 82793.86)
(7.0, 77368.06)
it's a tuple.
My idea is create a Json with the result above like this:
{'items': [{'value': 123.0, 'label': '460654.05)'}, {'value': 234.0, 'label': '292016.43)'}], and so on, 'auth_token': 'mysecret'}
I tried using a for.
for i in res:
n = {'items': [{'label': '0', 'value': '0', 'auth_token':
'Hues4onpDHtI2'}]}
n['items'][0]['label'] = i[0]
n['items'][0]['value'] = i[1]
the result was
{'items': [{'auth_token': 'mysecret', 'value': 460654.05, 'label': 123.0}]}
{'items': [{'auth_token': 'mysecret', 'value': 292016.43, 'label': 234.0}]}
Any ideas?