Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions shared/json_utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,19 @@ func IsSubset(json, superSet interface{}) bool {

// isMapSubset Helper function to check if objOne (map[string]interface{}) is a subset of objTwo
func isMapSubset(objOne, objTwo map[string]interface{}) bool {
// Accumulator to check if all key-value pairs in objOne exist in objTwo
objMatches := true
for key, valueObjOne := range objOne {
// Check if the key exists in objTwo
if valueObjTwo, exists := objTwo[key]; exists {
// Recursively check if the values are deeply equal
return IsSubset(valueObjOne, valueObjTwo)
objMatches = objMatches && IsSubset(valueObjOne, valueObjTwo)
} else {
// Key doesn't exist in objTwo
return false
}
}
return true
return objMatches
}

// isSliceSubset Helper function to check if arrOne ([]interface{}) is a subset of arrTwo
Expand Down