Improve usages of json.Unmarshal

This commit is contained in:
世界
2024-07-22 12:10:22 +08:00
parent 9b8d6c1b73
commit f4f5a3c925
3 changed files with 4 additions and 8 deletions

View File

@@ -1,8 +1,6 @@
package option
import (
"bytes"
"github.com/sagernet/sing/common"
E "github.com/sagernet/sing/common/exceptions"
"github.com/sagernet/sing/common/json"
@@ -69,7 +67,5 @@ func UnmarshallExcluded(inputContent []byte, parentObject any, object any) error
if err != nil {
return err
}
decoder := json.NewDecoder(bytes.NewReader(inputContent))
decoder.DisallowUnknownFields()
return decoder.Decode(object)
return json.UnmarshalDisallowUnknownFields(inputContent, object)
}