首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在具有多个json对象的python中解析json文件

无法在具有多个json对象的python中解析json文件
EN

Stack Overflow用户
提问于 2021-03-18 23:05:06
回答 1查看 20关注 0票数 0

我想用python解析一个包含多个json根元素的json文件,但是我得到了这个错误:

代码语言:javascript
复制
json.decoder.JSONDecodeError: Extra data: line 325 column 2 (char 11121) multiple json objects

下面是我正在尝试的代码:

代码语言:javascript
复制
data_json= json.load(open("C:/Users/myname/PycharmProjects/starting/newfile.json", 'r'))

以下是json在文件中的示例:

代码语言:javascript
复制
{
  "status": "OK",
  "result": {
    "data": {
      "totalIncidents": 203.0,
      "incidentItems": [
        {
          "violatorText": "UEBATest4 Account",
          "lastUpdateDate": 1615203657910,
          "violatorId": "5",
          "incidentId": "108662",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "LowMedium",
          "priority": "None",
          "reason": [
            "Number Of Threat: 1",
            "Resource: HC_MWS1",
            "Threat Model: Low Cloud AND PRI"
          ],
          "violatorSubText": "666666666",
          "entity": "Users",
          "workflowName": "Low_Medium",
          "url": "https://securityindex.com",
          "isWhitelisted": false,
          "watchlisted": true,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203657862,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest Account",
          "lastUpdateDate": 1615203657742,
          "violatorId": "1",
          "incidentId": "108640",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "LowMedium",
          "priority": "None",
          "reason": [
            "Number Of Threat: 1",
            "Threat Model: Low Email AND PRI"
          ],
          "violatorSubText": "888888888",
          "entity": "Users",
          "workflowName": "Low_Medium",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108640",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203657697,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest4 Account",
          "lastUpdateDate": 1615203657576,
          "violatorId": "5",
          "incidentId": "108618",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "LowMedium",
          "priority": "None",
          "reason": [
            "Number Of Threat: 1",
            "Resource: HC_MWS1",
            "Threat Model: Low Email AND PRI"
          ],
          "violatorSubText": "666666666",
          "entity": "Users",
          "workflowName": "Low_Medium",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108618",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203657529,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest Account",
          "lastUpdateDate": 1615203657413,
          "violatorId": "1",
          "incidentId": "108596",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "SecOps",
          "priority": "High",
          "reason": [
            "Number Of Threat: 1",
            "Threat Model: Medium Email AND PRI"
          ],
          "violatorSubText": "888888888",
          "entity": "Users",
          "workflowName": "IDP",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108596",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203657366,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest4 Account",
          "lastUpdateDate": 1615203657239,
          "violatorId": "5",
          "incidentId": "108574",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "SecOps",
          "priority": "High",
          "reason": [
            "Number Of Threat: 1",
            "Resource: HC_MWS1",
            "Threat Model: Medium Email AND PRI"
          ],
          "violatorSubText": "666666666",
          "entity": "Users",
          "workflowName": "IDP",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108574",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203657190,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest4 Account",
          "lastUpdateDate": 1615203657050,
          "violatorId": "5",
          "incidentId": "108552",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "SecOps",
          "priority": "High",
          "reason": [
            "Number Of Threat: 1",
            "Resource: HC_MWS1",
            "Threat Model: Medium Cloud AND PRI"
          ],
          "violatorSubText": "666666666",
          "entity": "Users",
          "workflowName": "IDP",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108552",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203657009,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest4 Account",
          "lastUpdateDate": 1615203656773,
          "violatorId": "5",
          "incidentId": "108530",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "SecOps",
          "priority": "High",
          "reason": [
            "Number Of Threat: 1",
            "Resource: HC_MWS1",
            "Threat Model: Medium Cloud AND PRI_SB"
          ],
          "violatorSubText": "666666666",
          "entity": "Users",
          "workflowName": "IDP",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108530",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": true,
          "parentCaseId": "",
          "casecreatetime": 1615203656733,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest Account",
          "lastUpdateDate": 1615203656624,
          "violatorId": "1",
          "incidentId": "108508",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "SecOps",
          "priority": "High",
          "reason": [
            "Number Of Threat: 1",
            "Threat Model: Medium USB AND PRI"
          ],
          "violatorSubText": "888888888",
          "entity": "Users",
          "workflowName": "IDP",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108508",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203656579,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest Account",
          "lastUpdateDate": 1615203656478,
          "violatorId": "1",
          "incidentId": "108486",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "SecOps",
          "priority": "High",
          "reason": [
            "Number Of Threat: 1",
            "Threat Model: WeTransfer Blocked violations"
          ],
          "violatorSubText": "888888888",
          "entity": "Users",
          "workflowName": "IDP",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108486",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203656436,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest Account",
          "lastUpdateDate": 1615203656327,
          "violatorId": "1",
          "incidentId": "108464",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "SecOps",
          "priority": "High",
          "reason": [
            "Number Of Threat: 1",
            "Threat Model: Medium CDDVD AND PRI"
          ],
          "violatorSubText": "888888888",
          "entity": "Users",
          "workflowName": "IDP",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108464",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203656282,
          "bulkactionallowed": true
        }
      ]
    }
  }
},
{
  "status": "OK",
  "result": {
    "data": {
      "totalIncidents": 203.0,
      "incidentItems": [
        {
          "violatorText": "UEBATest4 Account",
          "lastUpdateDate": 1615203657910,
          "violatorId": "5",
          "incidentId": "108662",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "LowMedium",
          "priority": "None",
          "reason": [
            "Number Of Threat: 1",
            "Resource: HC_MWS1",
            "Threat Model: Low Cloud AND PRI"
          ],
          "violatorSubText": "666666666",
          "entity": "Users",
          "workflowName": "Low_Medium",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108662",
          "isWhitelisted": false,
          "watchlisted": true,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203657862,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest Account",
          "lastUpdateDate": 1615203657742,
          "violatorId": "1",
          "incidentId": "108640",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "LowMedium",
          "priority": "None",
          "reason": [
            "Number Of Threat: 1",
            "Threat Model: Low Email AND PRI"
          ],
          "violatorSubText": "888888888",
          "entity": "Users",
          "workflowName": "Low_Medium",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108640",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203657697,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest4 Account",
          "lastUpdateDate": 1615203657576,
          "violatorId": "5",
          "incidentId": "108618",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "LowMedium",
          "priority": "None",
          "reason": [
            "Number Of Threat: 1",
            "Resource: HC_MWS1",
            "Threat Model: Low Email AND PRI"
          ],
          "violatorSubText": "666666666",
          "entity": "Users",
          "workflowName": "Low_Medium",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108618",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203657529,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest Account",
          "lastUpdateDate": 1615203657413,
          "violatorId": "1",
          "incidentId": "108596",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "SecOps",
          "priority": "High",
          "reason": [
            "Number Of Threat: 1",
            "Threat Model: Medium Email AND PRI"
          ],
          "violatorSubText": "888888888",
          "entity": "Users",
          "workflowName": "IDP",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108596",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203657366,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest4 Account",
          "lastUpdateDate": 1615203657239,
          "violatorId": "5",
          "incidentId": "108574",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "SecOps",
          "priority": "High",
          "reason": [
            "Number Of Threat: 1",
            "Resource: HC_MWS1",
            "Threat Model: Medium Email AND PRI"
          ],
          "violatorSubText": "666666666",
          "entity": "Users",
          "workflowName": "IDP",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108574",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203657190,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest4 Account",
          "lastUpdateDate": 1615203657050,
          "violatorId": "5",
          "incidentId": "108552",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "SecOps",
          "priority": "High",
          "reason": [
            "Number Of Threat: 1",
            "Resource: HC_MWS1",
            "Threat Model: Medium Cloud AND PRI"
          ],
          "violatorSubText": "666666666",
          "entity": "Users",
          "workflowName": "IDP",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108552",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203657009,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest4 Account",
          "lastUpdateDate": 1615203656773,
          "violatorId": "5",
          "incidentId": "108530",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "SecOps",
          "priority": "High",
          "reason": [
            "Number Of Threat: 1",
            "Resource: HC_MWS1",
            "Threat Model: Medium Cloud AND PRI_SB"
          ],
          "violatorSubText": "666666666",
          "entity": "Users",
          "workflowName": "IDP",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108530",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": true,
          "parentCaseId": "",
          "casecreatetime": 1615203656733,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest Account",
          "lastUpdateDate": 1615203656624,
          "violatorId": "1",
          "incidentId": "108508",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "SecOps",
          "priority": "High",
          "reason": [
            "Number Of Threat: 1",
            "Threat Model: Medium USB AND PRI"
          ],
          "violatorSubText": "888888888",
          "entity": "Users",
          "workflowName": "IDP",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108508",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203656579,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest Account",
          "lastUpdateDate": 1615203656478,
          "violatorId": "1",
          "incidentId": "108486",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "SecOps",
          "priority": "High",
          "reason": [
            "Number Of Threat: 1",
            "Threat Model: WeTransfer Blocked violations"
          ],
          "violatorSubText": "888888888",
          "entity": "Users",
          "workflowName": "IDP",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108486",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203656436,
          "bulkactionallowed": true
        },
        {
          "violatorText": "UEBATest Account",
          "lastUpdateDate": 1615203656327,
          "violatorId": "1",
          "incidentId": "108464",
          "incidentStatus": "Open",
          "riskscore": 0.0,
          "assignedGroup": "SecOps",
          "priority": "High",
          "reason": [
            "Number Of Threat: 1",
            "Threat Model: Medium CDDVD AND PRI"
          ],
          "violatorSubText": "888888888",
          "entity": "Users",
          "workflowName": "IDP",
          "url": "https://securityindex.comSnypr/configurableDashboards/view?\u0026type\u003dincident\u0026id\u003d108464",
          "isWhitelisted": false,
          "watchlisted": false,
          "tenantInfo": {
            "tenantid": 1,
            "tenantname": "DEV",
            "tenantcolor": "#000000",
            "tenantshortcode": "SE"
          },
          "statusCompleted": false,
          "sandBoxPolicy": false,
          "parentCaseId": "",
          "casecreatetime": 1615203656282,
          "bulkactionallowed": true
        }
      ]
    }
  }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-18 23:50:27

用文件开头的[和结尾的]包围json对象,使其成为json对象的数组,这样代码就知道要查找多个json对象。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66693749

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档