[ [id0, date0, time0, msg0], [id1, date1, time1, msg1] ]
[
{
"id": id0,
"date": date0,
"time": time0,
"msg": msg0,
},
{
"id": id1,
"date": date1,
"time": time1,
"msg": msg1,
},
import json
old_list = [ ["id0", "date0", "time0", "msg0"], ["id1", "date1", "time1", "msg1"] ]
new_list = []
for x in old_list:
d = {"id":x[0],
"date":x[1],
"time":x[2],
"msg":x[3]}
new_list.append(d)
final_json = json.dumps(new_list,indent=4)
print(final_json)
[
{
"id": "id0",
"date": "date0",
"time": "time0",
"msg": "msg0"
},
{
"id": "id1",
"date": "date1",
"time": "time1",
"msg": "msg1"
}
]