We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ae33bab commit 3cc7d0bCopy full SHA for 3cc7d0b
types/types.go
@@ -48,10 +48,13 @@ func (g *GzippedText) Scan(src interface{}) error {
48
// implements `Unmarshal`, which unmarshals the json within to an interface{}
49
type JsonText json.RawMessage
50
51
-var _EMPTY_JSON = []byte("{}")
+var _EMPTY_JSON = JsonText("{}")
52
53
// Returns the *j as the JSON encoding of j.
54
func (j *JsonText) MarshalJSON() ([]byte, error) {
55
+ if len(*j) == 0 {
56
+ *j = _EMPTY_JSON
57
+ }
58
return *j, nil
59
}
60
@@ -83,7 +86,11 @@ func (j *JsonText) Scan(src interface{}) error {
83
86
case string:
84
87
source = []byte(t)
85
88
case []byte:
- source = t
89
+ if len(t) == 0 {
90
+ source = _EMPTY_JSON
91
+ } else {
92
+ source = t
93
94
case nil:
95
*j = _EMPTY_JSON
96
default:
0 commit comments