diff --git a/Makefile b/Makefile index 9e540d7..ffb1396 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ test-json: go test -cover -race ./json test-json-bugs: - go test -cover -race ./json/bugs/... + go test -race ./json/bugs/... test-json-1.17: go test -cover -race -tags go1.17 ./json diff --git a/json/bugs/issue11/main.go b/json/bugs/issue11/main.go deleted file mode 100644 index 38dd16d..0000000 --- a/json/bugs/issue11/main.go +++ /dev/null @@ -1,3 +0,0 @@ -package main - -func main() {} diff --git a/json/bugs/issue136/main_test.go b/json/bugs/issue136/main_test.go new file mode 100644 index 0000000..044af10 --- /dev/null +++ b/json/bugs/issue136/main_test.go @@ -0,0 +1,23 @@ +package main + +import ( + "bytes" + "testing" + + "github.com/segmentio/encoding/json" +) + +func TestIssue136(t *testing.T) { + input := json.RawMessage(` null`) + + got, err := json.Marshal(input) + if err != nil { + t.Fatal(err) + } + + want := bytes.TrimSpace(input) + + if !bytes.Equal(got, want) { + t.Fatalf("Marshal(%q) = %q, want %q", input, got, want) + } +} diff --git a/json/bugs/issue18/main.go b/json/bugs/issue18/main.go deleted file mode 100644 index da29a2c..0000000 --- a/json/bugs/issue18/main.go +++ /dev/null @@ -1,4 +0,0 @@ -package main - -func main() { -} diff --git a/json/bugs/issue84/main.go b/json/bugs/issue84/main.go deleted file mode 100644 index 38dd16d..0000000 --- a/json/bugs/issue84/main.go +++ /dev/null @@ -1,3 +0,0 @@ -package main - -func main() {} diff --git a/json/encode.go b/json/encode.go index acb3b67..4173ddd 100644 --- a/json/encode.go +++ b/json/encode.go @@ -858,6 +858,7 @@ func (e encoder) encodeRawMessage(b []byte, p unsafe.Pointer) ([]byte, error) { s = v } else { var err error + v = skipSpaces(v) // don't assume that a RawMessage starts with a token. d := decoder{} s, _, _, err = d.parseValue(v) if err != nil { diff --git a/json/parse.go b/json/parse.go index 3e65621..49f63aa 100644 --- a/json/parse.go +++ b/json/parse.go @@ -709,7 +709,6 @@ func (d decoder) parseValue(b []byte) ([]byte, []byte, Kind, error) { case '{': v, b, k, err = d.parseObject(b) case '[': - k = Array v, b, k, err = d.parseArray(b) case '"': v, b, k, err = d.parseString(b)