Zum Beispiel, wenn Sie den Wert mit "ruleId" als Schlüssel erhalten möchten
test.json
{
"timestamp": 1604751455679,
"ruleGroupList": [
{
"ruleGroupId": "AWS#AWSManagedRulesCommonRuleSet",
"terminatingRule": {
"ruleId": "NoUserAgent_HEADER",
"action": "BLOCK",
"ruleMatchDetails": null
},
"nonTerminatingMatchingRules": [],
"excludedRules": null
}
]
}
jsn [" ruleGroupList "] [0] [" terminatingRule "] [" ruleId "]
import json
with open('test.json') as f:
jsn = json.load(f)
print(jsn["ruleGroupList"][0]["terminatingRule"]["ruleId"])
yuta:~ $ python jsontest.py
NoUserAgent_HEADER