json.go
971 字节
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package pgjson
import (
"encoding/json"
"io"
json2 "github.com/segmentio/encoding/json"
)
var _ Provider = (*StdProvider)(nil)
type StdProvider struct{}
func (StdProvider) Marshal(v interface{}) ([]byte, error) {
return json.Marshal(v)
}
func (StdProvider) Unmarshal(data []byte, v interface{}) error {
return json.Unmarshal(data, v)
}
func (StdProvider) NewEncoder(w io.Writer) Encoder {
return json.NewEncoder(w)
}
func (StdProvider) NewDecoder(r io.Reader) Decoder {
return json.NewDecoder(r)
}
var _ Provider = (*SegmentioProvider)(nil)
type SegmentioProvider struct{}
func (SegmentioProvider) Marshal(v interface{}) ([]byte, error) {
return json2.Marshal(v)
}
func (SegmentioProvider) Unmarshal(data []byte, v interface{}) error {
return json2.Unmarshal(data, v)
}
func (SegmentioProvider) NewEncoder(w io.Writer) Encoder {
return json2.NewEncoder(w)
}
func (SegmentioProvider) NewDecoder(r io.Reader) Decoder {
return json2.NewDecoder(r)
}