For example, when you want to get the value using " ruleId "
as a key
test.json
{
"timestamp": 1604751455679,
"ruleGroupList": [
{
"ruleGroupId": "AWS#AWSManagedRulesCommonRuleSet",
"terminatingRule": {
"ruleId": "NoUserAgent_HEADER",
"action": "BLOCK",
"ruleMatchDetails": null
},
"nonTerminatingMatchingRules": [],
"excludedRules": null
}
]
}
--Extract like 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
Recommended Posts