blob: 34cbfe40a7f939ad4dc1b865b81d9681893f25d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
package serde
import (
"fmt"
"io"
"github.com/google/jsonapi"
)
func ToPlain[T any](w io.Writer, item T) error {
if err, ok := any(item).(*jsonapi.ErrorsPayload); ok {
if len(err.Errors) == 1 {
_, err := w.Write([]byte(err.Errors[0].Title))
return err
}
}
_, err := w.Write([]byte(fmt.Sprintf("%v", item)))
return err
}
|