summaryrefslogtreecommitdiff
path: root/libgo/go/encoding/json/stream.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/encoding/json/stream.go')
-rw-r--r--libgo/go/encoding/json/stream.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/libgo/go/encoding/json/stream.go b/libgo/go/encoding/json/stream.go
index 87f0e57c6cd..95e30ce36d5 100644
--- a/libgo/go/encoding/json/stream.go
+++ b/libgo/go/encoding/json/stream.go
@@ -246,9 +246,12 @@ func (enc *Encoder) SetEscapeHTML(on bool) {
// be used to delay JSON decoding or precompute a JSON encoding.
type RawMessage []byte
-// MarshalJSON returns *m as the JSON encoding of m.
-func (m *RawMessage) MarshalJSON() ([]byte, error) {
- return *m, nil
+// MarshalJSON returns m as the JSON encoding of m.
+func (m RawMessage) MarshalJSON() ([]byte, error) {
+ if m == nil {
+ return []byte("null"), nil
+ }
+ return m, nil
}
// UnmarshalJSON sets *m to a copy of data.