我有一個包含數(shù)十萬行的 JSON 響應(yīng),所有這些都從字典 python 解析并使用 json.load 轉(zhuǎn)換為 JSON現(xiàn)在獲取無效響應(yīng)的 JSON 響應(yīng),因此解決方法如下回復(fù){ "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": ""}]這些我需要通過程序完成,當(dāng)我嘗試使用 sed shell --> #sed -i 's#}#},#' test.json <-- 。此 shell 命令替換 }, in }, 并返回為 },,
Python需要用(大括號和逗號)替換大括號
慕的地8271018
2022-12-06 15:01:32