You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-06-15 22:50:24 +02:00
support decode int key map
This commit is contained in:
@ -68,10 +68,17 @@ func Test_slice_of_map(t *testing.T) {
|
||||
should.Equal("2", val[0]["1"])
|
||||
}
|
||||
|
||||
func Test_write_int_key_map(t *testing.T) {
|
||||
func Test_encode_int_key_map(t *testing.T) {
|
||||
should := require.New(t)
|
||||
val := map[int]string{1: "2"}
|
||||
str, err := MarshalToString(val)
|
||||
should.Nil(err)
|
||||
should.Equal(`{"1":"2"}`, str)
|
||||
}
|
||||
|
||||
func Test_decode_int_key_map(t *testing.T) {
|
||||
should := require.New(t)
|
||||
var val map[int]string
|
||||
should.Nil(UnmarshalFromString(`{"1":"2"}`, &val))
|
||||
should.Equal(map[int]string{1: "2"}, val)
|
||||
}
|
Reference in New Issue
Block a user