Par exemple, lorsque vous souhaitez obtenir la valeur en utilisant " ruleId "
comme clé
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
Recommended Posts