use python 3.6
this json: [["10000000000"], ["12000000000"]]
i want get like result like
"data": {"calleeInfo": [{"phone": "10000000000",},{"phone": "12000000000",}]}
CodePudding user response:
By list generation
temp = [["10000000000"], ["12000000000"]]
value = [{"phone": i[0]} for i in temp]
result = {"data": {"calleeInfo": value}}
print(result)
Output
{'data': {'calleeInfo': [{'phone': '10000000000'}, {'phone': '12000000000'}]}}