1
0
mirror of https://github.com/json-iterator/go.git synced 2024-11-27 08:30:57 +02:00

fix 1.6 compatibility

This commit is contained in:
Tao Wen 2017-07-02 13:22:55 +08:00
parent 11975d2a26
commit 368bd0c1d8

View File

@ -166,7 +166,7 @@ func (encoder *sortKeysMapEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
// Extract and sort the keys.
keys := realVal.MapKeys()
sv := make([]reflectWithString, len(keys))
sv := stringValues(make([]reflectWithString, len(keys)))
for i, v := range keys {
sv[i].v = v
if err := sv[i].resolve(); err != nil {
@ -174,7 +174,7 @@ func (encoder *sortKeysMapEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
return
}
}
sort.Slice(sv, func(i, j int) bool { return sv[i].s < sv[j].s })
sort.Sort(sv)
stream.WriteObjectStart()
for i, key := range sv {