I try to check if object A is part of object B. As can be seen, all key-value pairs from object A are also contained in object B. Object A comes from a YAML file (yaml.safe_load()), object B is the result of an API query (requests.get().json()). Both are of type (with type()): <class 'dict'>
Example objects:
Object A
{
"title": "Filebeat",
"type": "org.graylog.plugins.beats.Beats2Input",
"global": true,
"configuration": {
"bind_address": "0.0.0.0",
"port": 5044,
"tls_enable": false,
"no_beats_prefix": false
}
}
Object B
{
"title": "Filebeat",
"global": true,
"name": "Beats",
"created_at": "2020-07-27T12:20:57.041Z",
"type": "org.graylog.plugins.beats.Beats2Input",
"creator_user_id": "admin",
"attributes": {
"bind_address": "0.0.0.0",
"port": 5044,
"tls_enable": false,
"no_beats_prefix": false
},
"static_fields": {},
"node": "None",
}
I am thinking of:
if array_a.ispart(array_b):
...
I've already checked this post (Python: Check if one dictionary is a subset of another larger dictionary), but it doesn't work for me. Maybe because of the nested arrays.