-
Notifications
You must be signed in to change notification settings - Fork 1
/
json.go
28 lines (24 loc) · 813 Bytes
/
json.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package json
import (
"bytes"
"io"
)
// The Json interface is used to customize the json handler.
// Five wrappers are provided by default. For detailed documentation,
// see: https://pkg.go.dev/github.com/3JoB/telebot/v2/pkg/json.
//
// Some methods use the default sonnet because they are not under *Bot.
type Json interface {
Marshal(v any) ([]byte, error)
MarshalIndent(v any, prefix string, indent string) ([]byte, error)
Unmarshal(buf []byte, v any) error
NewEncoder(w io.Writer) Encoder
NewDecoder(r io.Reader) Decoder
Indent(dst *bytes.Buffer, src []byte, prefix string, indent string) error
}
type Encoder interface {
Encode(v any) error
}
type Decoder interface {
Decode(v any) error // Decode reads the next JSON-encoded value from its input and stores it in the value pointed to by v.
}