1
0
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:
Tao Wen
2017-06-05 23:53:48 +08:00
parent 29dc1d407d
commit af4982b22c
3 changed files with 44 additions and 4 deletions

View File

@ -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)
}