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 9, 2025
1 parent aa7d254 commit be9840c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions common/json/badoption/listable.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,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 be9840c

Please sign in to comment.