mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-13 21:54:13 +08:00
fix: error handling
This commit is contained in:
parent
39dbb8c156
commit
0c47e2c0c2
@ -94,8 +94,9 @@ func (l Listable[T]) MarshalJSON() ([]byte, error) {
|
||||
func (l *Listable[T]) UnmarshalJSON(content []byte) (err error) {
|
||||
if len(content) > 0 && content[0] != '[' {
|
||||
var element T
|
||||
err = json.Unmarshal(content, &element)
|
||||
*l = []T{element}
|
||||
if err = json.Unmarshal(content, &element); err == nil {
|
||||
*l = []T{element}
|
||||
}
|
||||
return
|
||||
}
|
||||
return json.Unmarshal(content, (*[]T)(l))
|
||||
|
Loading…
x
Reference in New Issue
Block a user