import json
json_str = r"""
{
"group 1": [{
"index": 8,
"API name": "RegOpenKey",
"params": {
"hKey": "HKEY_CURRENT_USER\\Control Panel\\Desktop"
},
"action": "Read"
},
{
"index": 9,
"API name": "RegQueryValue",
"params": {
"hKey": "HKEY_CURRENT_USER\\Control Panel\\Desktop\\SmoothScroll"
},
"action": "Read"
},
{
"index": 10,
"API name": "RegCloseKey",
"params": {
"hKey": "HKEY_CURRENT_USER\\Control Panel\\Desktop"
},
"action": "Close"
},
{
"index": 54,
"API name": "RegOpenKey",
"params": {
"hKey": "HKEY_CURRENT_USER\\Control Panel\\Desktop"
},
"action": "Read"
},
{
"index": 55,
"API name": "RegQueryValue",
"params": {
"hKey": "HKEY_CURRENT_USER\\Control Panel\\Desktop\\SmoothScroll"
},
"action": "Read"
},
{
"index": 56,
"API name": "RegCloseKey",
"params": {
"hKey": "HKEY_CURRENT_USER\\Control Panel\\Desktop"
},
"action": "Close"
}
],
"group 2": [{
"index": 8,
"API name": "RegOpenKey",
"params": {
"hKey": "HKEY_CURRENT_USER\\Control Panel\\Desktop"
},
"action": "Read"
}]
}"""
data = json.loads(json_str)
def haveKeyWord(l, keyword):
_ = list(filter(lambda x: keyword in x['params']['hKey'].split("\\"), l))
return True if _ else False
result = dict(filter(lambda x:haveKeyWord(x[1], "SmoothScroll"), data.items()))
print(result.keys())
aW1wb3J0IGpzb24KCmpzb25fc3RyID0gciIiIgp7CgkiZ3JvdXAgMSI6IFt7CgkJCSJpbmRleCI6IDgsCgkJCSJBUEkgbmFtZSI6ICJSZWdPcGVuS2V5IiwKCQkJInBhcmFtcyI6IHsKCQkJCSJoS2V5IjogIkhLRVlfQ1VSUkVOVF9VU0VSXFxDb250cm9sIFBhbmVsXFxEZXNrdG9wIgoJCQl9LAoJCQkiYWN0aW9uIjogIlJlYWQiCgkJfSwKCQl7CgkJCSJpbmRleCI6IDksCgkJCSJBUEkgbmFtZSI6ICJSZWdRdWVyeVZhbHVlIiwKCQkJInBhcmFtcyI6IHsKCQ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