Skip to content
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

fix frozeWithCacheReuse #639

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

molon
Copy link
Contributor

@molon molon commented Sep 28, 2022

func Test_customize_map_key_encoder(t *testing.T) {
	should := require.New(t)
	cfg := jsoniter.Config{}.Froze()
	cfg.RegisterExtension(&testMapKeyExtension{})
	m := map[int]int{1: 2}

	b, err := cfg.MarshalIndent(m, "", "  ")
	should.NoError(err)
	should.Equal(`{
  "2": 2
}`, string(b))

	cfg = jsoniter.Config{}.Froze() // without testMapKeyExtension
	b, err = cfg.MarshalIndent(m, "", "  ")
	should.NoError(err)
// !!!!! Before fix, it won't be equal here !!!!!!!
	should.Equal(`{
  "1": 2
}`, string(b))
}

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

Successfully merging this pull request may close these issues.

None yet

1 participant