]> Cypherpunks repositories - gostls13.git/commit
encoding/json: marshal with null when RawMessage is nil
authorJoe Tsai <joetsai@digital-static.net>
Tue, 1 Nov 2016 00:34:42 +0000 (17:34 -0700)
committerJoe Tsai <thebrokentoaster@gmail.com>
Tue, 1 Nov 2016 05:42:33 +0000 (05:42 +0000)
commit032d150bd4a812eee9c3ea017f0d3acc8c484325
tree0b0fe38fb69f32ea68d6de185417ec585b4ae58e
parent7a26d9fcedd94a1ba0d95833b0cdbbdcc776fe19
encoding/json: marshal with null when RawMessage is nil

This CL expands upon a change made in (http://golang.org/cl/21811)
to ensure that a nil RawMessage gets serialized as "null" instead of
being a nil slice.

The added check only triggers when the RawMessage is nil. We do not
handle the case when the RawMessage is non-nil, but empty.

Fixes #17704
Updates #14493

Change-Id: I0fbebcdd81f7466c5b78c94953afc897f162ceb4
Reviewed-on: https://go-review.googlesource.com/32472
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/encoding/json/encode_test.go
src/encoding/json/stream.go