我有一些JSON文本我想遍历,以下列方式格式化:迭代通过的Json列表对象 - Python的
{
"itemsPerPage": 45,
"links": {
"next": "https://www.12345.com"
},
"list": [
{
"id": "333333",
"placeID": "63333",
"description": " ",
"displayName": "test-12345",
"name": "test",
"status": "Active",
"groupType": "Creative",
"groupTypeV2": "Public",
"memberCount": 1,
},
{
"id": "32423",
"placeID": "606",
"description": " ",
"displayName": "test123",
"name": "test",
"status": "Active",
"groupType": "Creative",
"groupTypeV2": "Private",
"memberCount": 1,
},
我想通过这个列表进行迭代,并且然而抢显示名,我代码将无法识别所有不同的显示名称。这里是我的代码:
for i in range(len(json_obj['list'])):
if (json_obj['list'][i]['displayName'] == "some id"):
do stuff
else:
exit()
我该如何修复语句,以便成功循环json obj?
这不是一个有效的JSON对象。 –
是什么让它不是一个有效的obj? – pokemongirl1234
如何使用此obj来迭代并查找显示名称? – pokemongirl1234