I have a source JSON with several keys and values and I'd like to take several target JSONs and check if they are a subset of that JSON: all fields in target JSON are present in source JSON and hold the same values.
To accomplish this, I'd like to place several values of different types in the value part of a HashMap
and call equals
on those values.
There are several types of values in the map and I'd like to accept some key-value pair and check if
- the key is in the map
- the value is the same as the value in the map.
This is an example of what I'd like to do in Java:
boolean isInMap(Map<String, Object> map, String key, Object value) {
return map.containsKey(key) && map.get(key).equals(value);
}
This might be an XY question but how can I do this in Rust?