pkg/json/json.go   A
last analyzed

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 18
dl 0
loc 33
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A json.*NativeJSON.Marshal 0 2 1
A json.*JSON.Unmarshal 0 2 1
A json.*NativeJSON.Unmarshal 0 2 1
A json.NewJSON 0 2 1
A json.*JSON.Marshal 0 2 1
1
package json
2
3
import "encoding/json"
4
5
type Helper interface {
6
	Marshal(v interface{}) ([]byte, error)
7
	Unmarshal(data []byte, v interface{}) error
8
}
9
10
type JSON struct {
11
	json Helper
12
}
13
14
func NewJSON(json Helper) *JSON {
15
	return &JSON{json: json}
16
}
17
18
func (j *JSON) Marshal(v interface{}) ([]byte, error) {
19
	return j.json.Marshal(v)
20
}
21
22
func (j *JSON) Unmarshal(data []byte, v interface{}) error {
23
	return j.json.Unmarshal(data, v)
24
}
25
26
type NativeJSON struct{}
27
28
func (n *NativeJSON) Marshal(v interface{}) ([]byte, error) {
29
	return json.Marshal(v)
30
}
31
32
func (n *NativeJSON) Unmarshal(data []byte, v interface{}) error {
33
	return json.Unmarshal(data, v)
34
}
35