在参考了这个链接后,我遇到了一个情况,即我收到的响应中包含多个JSON对象。与链接中提到的响应(它接收一个包含多个JSON的单个数组)不同,我收到的多个JSON对象之间没有方括号包围,也没有逗号分隔。
响应数据的结构如下所示:
{
"self": "https://example1.com",
"key": "keyOne",
"name": "nameOne",
"emailAddress": "mailOne",
"avatarUrls": {
"48x48": "https://test.com/secure/useravatar?avatarId=1",
"24x24": "https://test.com/secure/useravatar?size=small&avatarId=1",
"16x16": "https://test.com/secure/useravatar?size=xsmall&avatarId=1",
"32x32": "https://test.com/secure/useravatar?size=medium&avatarId=1"
},
"displayName": "displayNameOne",
"active": true,
"timeZone": "Europe",
"locale": "en_UK"
}
{
"self": "https://example2.com",
"key": "keyTwo",
"name": "nameTwo",
"emailAddress": "mailTwo",
"avatarUrls": {
"48x48": "https://test.com/secure/useravatar?avatarId=2",
"24x24": "https://test.com/secure/useravatar?size=small&avatarId=2",
"16x16": "https://test.com/secure/useravatar?size=xsmall&avatarId=2",
"32x32": "https://test.com/secure/useravatar?size=medium&avatarId=2"
},
"displayName": "displayNameTwo",
"active": false,
"timeZone": "Europe",
"locale": "en_US"
}
我尝试遍历REST API响应,并考虑将响应内容用方括号包裹起来,但都没有成功。
我又查看了这个链接,但这里的情况是每个JSON元素都在单独一行,这与我的情况不符。请问,在Python中应如何处理这个问题呢?