listable: Fix incorrect unmarshaling of null to []T{null}

This commit is contained in:
世界 2025-01-08 11:04:24 +08:00
parent aa7d2543a3
commit be9840c70f
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -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 {