Skip to content

Commit 8374689

Browse files
authored
Merge pull request #4 from lefinal/fix-raw-message-issues
fix: raw json raw message treating null as valid again
2 parents b0ec9be + abee5e9 commit 8374689

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

json_raw_message.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (rm JSONRawMessage) MarshalJSON() ([]byte, error) {
3535
// UnmarshalJSON as json.RawMessage or sets Valid to false if empty.
3636
func (rm *JSONRawMessage) UnmarshalJSON(data []byte) error {
3737
// Do NOT use regular NULL-check here.
38-
if data == nil {
38+
if isNull(data) {
3939
rm.Valid = false
4040
rm.RawMessage = nil
4141
return nil

json_raw_message_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (suite *JSONRawMessageUnmarshalJSONSuite) TestNull() {
7373
}
7474
err := json.Unmarshal([]byte(`{"rm": null}`), &s)
7575
suite.Require().NoError(err, "should not fail")
76-
suite.True(s.RM.Valid, "should not be valid")
76+
suite.False(s.RM.Valid, "should not be valid")
7777
}
7878

7979
func (suite *JSONRawMessageUnmarshalJSONSuite) TestOK() {

0 commit comments

Comments
 (0)