1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00

#54 support sort map keys

This commit is contained in:
Tao Wen
2017-06-16 16:46:30 +08:00
parent e0e2423e9a
commit 69bc64b6d8
4 changed files with 110 additions and 10 deletions

View File

@ -125,3 +125,17 @@ func Test_map_key_with_escaped_char(t *testing.T) {
should.Equal(map[string]string{"k\"ey": "val"}, obj.Map)
}
}
func Test_encode_map_with_sorted_keys(t *testing.T) {
should := require.New(t)
m := map[string]interface{}{
"3": 3,
"1": 1,
"2": 2,
}
bytes, err := json.Marshal(m)
should.Nil(err)
output, err := ConfigCompatibleWithStandardLibrary.MarshalToString(m)
should.Nil(err)
should.Equal(string(bytes), output)
}