File tree Expand file tree Collapse file tree 2 files changed +11
-22
lines changed Expand file tree Collapse file tree 2 files changed +11
-22
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ package json
66
77import (
88 "bytes"
9- "errors "
9+ "encoding/json "
1010 "io"
1111)
1212
@@ -259,27 +259,7 @@ func (enc *Encoder) SetEscapeHTML(on bool) {
259259// RawMessage is a raw encoded JSON value.
260260// It implements Marshaler and Unmarshaler and can
261261// be used to delay JSON decoding or precompute a JSON encoding.
262- type RawMessage []byte
263-
264- // MarshalJSON returns m as the JSON encoding of m.
265- func (m RawMessage ) MarshalJSON () ([]byte , error ) {
266- if m == nil {
267- return []byte ("null" ), nil
268- }
269- return m , nil
270- }
271-
272- // UnmarshalJSON sets *m to a copy of data.
273- func (m * RawMessage ) UnmarshalJSON (data []byte ) error {
274- if m == nil {
275- return errors .New ("json.RawMessage: UnmarshalJSON on nil pointer" )
276- }
277- * m = append ((* m )[0 :0 ], data ... )
278- return nil
279- }
280-
281- var _ Marshaler = (* RawMessage )(nil )
282- var _ Unmarshaler = (* RawMessage )(nil )
262+ type RawMessage = json.RawMessage
283263
284264// A Token holds a value of one of these types:
285265//
Original file line number Diff line number Diff line change @@ -1236,3 +1236,12 @@ func TestMaintainOrderingIndented(t *testing.T) {
12361236 })
12371237 }
12381238}
1239+
1240+ // This is a compile time check that encoding/json's RawMessage can be used in Operation
1241+ func init () {
1242+ msg := json .RawMessage ([]byte (`1` ))
1243+
1244+ _ = Operation {
1245+ "foo" : & msg ,
1246+ }
1247+ }
You can’t perform that action at this time.
0 commit comments