Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

Marshal RawMessage is not CompatibleWithStandardLibrary #411

@cocktail18

Description

@cocktail18

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions