我已经用python导入了一个json文件,并且仍然读取了第一个json元素
我需要添加一个循环来读取所有文件
JSON文件内容[
{
"severity": 4,
"status": "OPEN",
"id": 1987,
"description": "Multiple Login Failures for the Same User containing Bad Username",
"start_time": 1525269490400
},
{
"severity": 4,
"status": "OPEN",
"id": 1986,
"description": "Multiple Login Failures for the Same User containing Bad Username",
"start_time": 1525269181679
},
.
.
.
.
.
]
这是python脚本# Prepare the sample Alert
with open('output.json') as json_data:
data = json.load(json_data,)
if severity=data[0]['severity'] < 4:
severity=1
elif severity=data[0]['severity'] > 6:
severity=3
else:
severity=2
alert = Alert(title=data[0]['description'],
date=data[0]['start_time'],
severity=severity,
description='N/A',
type='Offense',
source='QradarSiem',
sourceRef=data[0]['id'])
我知道我需要用for line in f:
data.append(json.loads(line))
但我不知道在哪里以及如何使用它,你能帮忙吗?