Home > Net >  python handle json list format to array list
python handle json list format to array list

Time:03-31

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'}]}}
  • Related