Skip to content

Marshal RawMessage is not CompatibleWithStandardLibrary #411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cocktail18 opened this issue Oct 12, 2019 · 1 comment
Open

Marshal RawMessage is not CompatibleWithStandardLibrary #411

cocktail18 opened this issue Oct 12, 2019 · 1 comment

Comments

@cocktail18
Copy link

Version: v1.1.7
Here is the code

import (
	"bytes"
	json2 "encoding/json"
	"testing"
)
var json = jsoniter.ConfigCompatibleWithStandardLibrary

type Test struct {
	Message json2.RawMessage
}

func TestJson(t *testing.T) {
	test := &Test{}
	test.Message = []byte("123")
	data, _ := json.Marshal(test)
	data2, _ := json2.Marshal(test)
	if bytes.Compare(data, data2) != 0 {
		t.Errorf("data: %s != data2 %s", data, data2)
	}
}

output:

=== RUN   TestJson
--- FAIL: TestJson (0.00s)
    handler_test.go:19: data: {"Message":null} != data2 {"Message":123}
FAIL
@robfig
Copy link
Contributor

robfig commented Oct 22, 2019

I think this is a dupe of #389

zhenzou pushed a commit to zhenzou/jsoniter that referenced this issue Feb 2, 2022
zhenzou pushed a commit to zhenzou/jsoniter that referenced this issue Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants