You've already forked json-iterator
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:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user