我有一個包含數十萬行的 JSON 響應,所有這些都從字典 python 解析并使用 json.load 轉換為 JSON現在獲取無效響應的 JSON 響應,因此解決方法如下回復{ "ComplianceType": "", "Details": { "InstalledTime": "", "PatchBaselineId": "", "PatchState": "" }, "ExecutionSummary": { "ExecutionId": "", "ExecutionTime": "", "ExecutionType": "" }, "Id": "", "ResourceId": "", "ResourceType": "", "Severity": "", "Status": "", "Title": ""}{ "ComplianceType": "", "Details": { "InstalledTime": "", "PatchBaselineId": "", "PatchState": "" }, "ExecutionSummary": { "ExecutionId": "", "ExecutionTime": "", "ExecutionType": "" }, "Id": "", "ResourceId": "", "ResourceType": "", "Severity": "", "Status": "", "Title": ""}變通使其有效[{ "ComplianceType": "", "Details": { "InstalledTime": "", "PatchBaselineId": "", "PatchState": "" }, "ExecutionSummary": { "ExecutionId": "", "ExecutionTime": "", "ExecutionType": "" }, "Id": "", "ResourceId": "", "ResourceType": "", "Severity": "", "Status": "", "Title": ""},{ "ComplianceType": "", "Details": { "InstalledTime": "", "PatchBaselineId": "", "PatchState": "" }, "ExecutionSummary": { "ExecutionId": "", "ExecutionTime": "", "ExecutionType": "" }, "Id": "", "ResourceId": "", "ResourceType": "", "Severity": "", "Status": "", "Title": ""}]這些我需要通過程序完成,當我嘗試使用 sed shell --> #sed -i 's#}#},#' test.json <-- 。此 shell 命令替換 }, in }, 并返回為 },,
Python需要用(大括號和逗號)替換大括號
慕的地8271018
2022-12-06 15:01:32