You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-06-15 22:50:24 +02:00
#16 fix slice of map
This commit is contained in:
@ -56,3 +56,14 @@ func Test_write_val_map(t *testing.T) {
|
||||
should.Nil(err)
|
||||
should.Equal(`{"1":"2"}`, str)
|
||||
}
|
||||
|
||||
func Test_slice_of_map(t *testing.T) {
|
||||
should := require.New(t)
|
||||
val := []map[string]string{{"1": "2"}}
|
||||
str, err := MarshalToString(val)
|
||||
should.Nil(err)
|
||||
should.Equal(`[{"1":"2"}]`, str)
|
||||
val = []map[string]string{}
|
||||
should.Nil(UnmarshalFromString(str, &val))
|
||||
should.Equal("2", val[0]["1"])
|
||||
}
|
Reference in New Issue
Block a user