Skip to content

Commit

Permalink
listable: Fix incorrect unmarshaling of null to []T{null}
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Jan 8, 2025
1 parent aa7d254 commit 026d949
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion common/json/badoption/listable.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package badoption

import (
"context"

Check failure on line 4 in common/json/badoption/listable.go

View workflow job for this annotation

GitHub Actions / Build

File is not properly formatted (gci)

E "github.com/sagernet/sing/common/exceptions"
"github.com/sagernet/sing/common/json"
)
Expand All @@ -18,6 +17,9 @@ func (l Listable[T]) MarshalJSONContext(ctx context.Context) ([]byte, error) {
}

func (l *Listable[T]) UnmarshalJSONContext(ctx context.Context, content []byte) error {
if string(content) == "null" {
return nil
}
var singleItem T
err := json.UnmarshalContextDisallowUnknownFields(ctx, content, &singleItem)
if err == nil {
Expand Down

0 comments on commit 026d949

Please sign in to comment.