Jun-16-2019, 08:05 AM
Hey,
i have this list of tuples, i need to arrange the output in json by order.
in nvm i have 3 list of tuple
it might be 10 lists.
i tried something with len to help me know how many lists i got but i didn't succeed
records[0] records[1] records[2] and if i have more i need some loop\ append to help me with it.
please help
Thank you!
i have this list of tuples, i need to arrange the output in json by order.
in nvm i have 3 list of tuple
>>> nvm = [(10, ['cp5'], ['ERROR'], 201905021800.0, 201905021900.0, [[1.2], [1.5]]), (11, ['cp3'], ['ERROR'], 201905021800.0, 201905021900.0, [[1.2], [1.5]]), (12, ['cp7', 'cp4'], ['ERROR'], 201905021800.0, 201905021900.0, [[1.2], [1.5]])] >>> type(nvm) <class 'list'> >>> type(nvm[0]) <class 'tuple'> >>>and i want to order it with loop and append because results always changing and next time
it might be 10 lists.
i tried something with len to help me know how many lists i got but i didn't succeed
#for lists in len(records) # listnum = range(lists) records = { "event_id": nvm[0][0] , "cp_ids": nvm[0][1] , "event_type": nvm[0][2] , "start_ts": nvm[0][3] , "end_ts": nvm[0][4] , "record": nvm[0][5] } return json.dumps(records)this does work but only for records[0] list, i need it for all the lists
records[0] records[1] records[2] and if i have more i need some loop\ append to help me with it.
please help
Thank you!