Commit ba949ac5 by CaIon

fix(override): handle null value comparison in JSON equality check

parent 758cd2c1
...@@ -238,6 +238,11 @@ func compareGjsonValues(jsonValue, targetValue gjson.Result, mode string) (bool, ...@@ -238,6 +238,11 @@ func compareGjsonValues(jsonValue, targetValue gjson.Result, mode string) (bool,
} }
func compareEqual(jsonValue, targetValue gjson.Result) (bool, error) { func compareEqual(jsonValue, targetValue gjson.Result) (bool, error) {
// 对null值特殊处理:两个都是null返回true,一个是null另一个不是返回false
if jsonValue.Type == gjson.Null || targetValue.Type == gjson.Null {
return jsonValue.Type == gjson.Null && targetValue.Type == gjson.Null, nil
}
// 对布尔值特殊处理 // 对布尔值特殊处理
if (jsonValue.Type == gjson.True || jsonValue.Type == gjson.False) && if (jsonValue.Type == gjson.True || jsonValue.Type == gjson.False) &&
(targetValue.Type == gjson.True || targetValue.Type == gjson.False) { (targetValue.Type == gjson.True || targetValue.Type == gjson.False) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment