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

fix frozeWithCacheReuse - #639

Open
molon wants to merge 2 commits into
json-iterator:masterfrom
molon:fix-frozeWithCacheReuse
Open

molon wants to merge 2 commits into
json-iterator:masterfrom
molon:fix-frozeWithCacheReuse

Conversation

@molon

@molon molon commented Sep 28, 2022

Copy link
Copy Markdown
Contributor
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

1 participant