Python: converting a list of dictionaries to json

前端 未结 4 1025
陌清茗
陌清茗 2020-12-08 03:54

I have a list of dictionaries, looking some thing like this:

list = [{\'id\': 123, \'data\': \'qwerty\', \'indices\': [1,10]}, {\'id\': 345, \'data\': \'mnbv         


        
4条回答
  •  离开以前
    2020-12-08 04:46

    response_json = ("{ \"response_json\":" + str(list_of_dict)+ "}").replace("\'","\"")
    response_json = json.dumps(response_json)
    response_json = json.loads(response_json)
    

提交回复
热议问题