python - 使用 Python 解析具有多个 json 的文本文件
问题描述
在更新关闭时重新发布问题
{
"schema": "2.0",
"comp": [
"fid1"
],
"name": "Temp1",
"type": "type1",
"attr": {
"version": "10.2.0.3"
}
}
{
"time": "18:21:58",
"process": "Start",
"msg": "Start"
}
我想将其解析为多个 JSON 对象。我尝试使用 json.load 但由于它不是纯 json 文件,它不起作用。其他选项是:
- 读取类似字符串并基于开始和结束括号,捕获 JSON。这种方法的缺点是如果文件太大,它会很复杂
- 根据新行和空格进行拆分。
有没有其他方法可以解析并且即使文件大小增加也可以适应?此外,文件中的 JSON 可以不同。
解决方案
推荐阅读
- java - Integer.parseInt(request.getParamerter("") thorws java.lang.NumberFormatException: null
- r - 如何使用变量选择数据框中的列
- c# - true 和 false 布尔返回值的结构
- excel - 使用 vbnewline 或 chr(10) 时,作为字符串变量的 DIM 文本不显示换行符或空格
- cmd - 查找动态变量的初始环境变量值?
- html - 在简单幻灯片旁边使用 MultiItem Bootstrap Carousel SlideShow
- c# - 获取对变量的引用并避免不必要地复制它
- kubernetes - 为什么busybox pod在exitCode 0完成后不断重启
- angular - 如何将可观察结果限制为一定数量的 rxjs
- r - 字符值问题