如何从字典中删除/删除大括号/大括号?

时间:2020-08-04 02:06:21

标签: python json dictionary

我的JSON响应如下所示。我想删除大括号(周围带有**),以便获取卡密钥中的值。我可以这样做吗,还是会弄乱整个词典?如果是这样,我想在大括号前(在**之前)分配键值。

希望有人可以帮助我解决这个问题,如果您能给我有关python字典的进一步说明,我会很高兴!

[
    **{**
        "board": {
            "id": "5f2106f0a188d073ebf3604b",
            "name": "TrAPI_test",
            "shortLink": "OIeEN1vG"
        },
        "card": {
            "id": "5f236a13a64ee90e7ef95341",
            "idShort": 3,
            "name": "task3",
            "shortLink": "WNHiHWxh"
        },
        "idMember": "5e1d96663a14c86d44d0edc4",
        "member": {
            "id": "5e1d96663a14c86d44d0edc4",
            "name": "Zorigt"
        }
    **}**,
    {
        "board": {
            "id": "5f2106f0a188d073ebf3604b",
            "name": "TrAPI_test",
            "shortLink": "OIeEN1vG"
        },
        "card": {
            "id": "5f236a13a64ee90e7ef95341",
            "idShort": 3,
            "name": "task3",
            "shortLink": "WNHiHWxh"
        },
        "list": {
            "id": "5f22161e221bea80b90d96ad",
            "name": "SprintTask"
        }
    }

]

1 个答案:

答案 0 :(得分:0)

我之所以能够得到它,是因为它一直是多个字典的列表:))

{
    "0": {
        "board": {
            "id": "5f2106f0a188d073ebf3604b",
            "name": "TrAPI_test",
            "shortLink": "OIeEN1vG"
        },
        "card": {
            "id": "5f236a13a64ee90e7ef95341",
            "idShort": 3,
            "name": "task3",
            "shortLink": "WNHiHWxh"
        },
        "idMember": "5e1d96663a14c86d44d0edc4",
        "member": {
            "id": "5e1d96663a14c86d44d0edc4",
            "name": "Zorigt"
        }
    },
    "1": {
        "board": {
            "id": "5f2106f0a188d073ebf3604b",
            "name": "TrAPI_test",
            "shortLink": "OIeEN1vG"
        },
        "card": {
            "id": "5f236a13a64ee90e7ef95341",
            "idShort": 3,
            "name": "task3",
            "shortLink": "WNHiHWxh"
        },
        "list": {
            "id": "5f22161e221bea80b90d96ad",
            "name": "SprintTask"
        }
    }
}

使用此

Dict_convert= {}
for idx, val in enumerate(List): 
    Dict_convert[idx] = val