javascript - Adding multiple levels of brackets to convert JSON format
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-19 10:47:32
0
1
642
{
    "1":"文去",
    "2":"147",
}

needs to be changed to

[
    {
        "name": "1", 
        "value": "文去"
    }, 
    {
        "name": "2", 
        "value": "147"
    }
]
曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(1)
淡淡烟草味

Idea: Take out the key and value in the dictionary to form a new res_dic, and append res_dic to the list as an item in res_list.

res_list = []
res_dic = {}
for k,v in dic.items():
    res_dic = {
        'name':v,
        'value':k
        }
    res_list.append(res_dic)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template