MCPcopy
hub / github.com/keploy/keploy / compareJSONTextWithNoise

Function compareJSONTextWithNoise

pkg/util.go:1627–1642  ·  view source on GitHub ↗
(expected, actual string, jsonNoiseKeys map[string]struct{})

Source from the content-addressed store, hash-verified

1625}
1626
1627func compareJSONTextWithNoise(expected, actual string, jsonNoiseKeys map[string]struct{}) (bool, error) {
1628 var exp any
1629 var act any
1630
1631 if err := json.Unmarshal([]byte(expected), &exp); err != nil {
1632 return false, err
1633 }
1634 if err := json.Unmarshal([]byte(actual), &act); err != nil {
1635 return false, err
1636 }
1637
1638 exp = removeGlobalNoiseKeys(exp, jsonNoiseKeys)
1639 act = removeGlobalNoiseKeys(act, jsonNoiseKeys)
1640
1641 return reflect.DeepEqual(exp, act), nil
1642}
1643
1644func removeGlobalNoiseKeys(node any, jsonNoiseKeys map[string]struct{}) any {
1645 switch v := node.(type) {

Callers 3

compareNDJSONStreamFunction · 0.85
compareSSEFieldsFunction · 0.85
compareMultipartPartFunction · 0.85

Calls 2

removeGlobalNoiseKeysFunction · 0.85
UnmarshalMethod · 0.80

Tested by

no test coverage detected