1
0
mirror of https://github.com/json-iterator/go.git synced 2025-04-20 11:28:49 +02:00

fix #239, empty slice

This commit is contained in:
Tao Wen 2018-02-21 07:24:22 +08:00
parent 404d90796f
commit ea6403326b
4 changed files with 22 additions and 22 deletions

View File

@ -1,11 +1,8 @@
package jsoniter
import (
"encoding"
"encoding/json"
"fmt"
"reflect"
"time"
"unsafe"
"github.com/v2pro/plz/reflect2"
)

View File

@ -78,7 +78,7 @@ func (decoder *sliceDecoder) doDecode(ptr unsafe.Pointer, iter *Iterator) {
}
c = iter.nextToken()
if c == ']' {
sliceType.Set(ptr, sliceType.UnsafeNew())
sliceType.UnsafeSet(ptr, sliceType.UnsafeMakeSlice(0, 0))
return
}
iter.unreadByte()

View File

@ -10,5 +10,8 @@ func init() {
unmarshalCases = append(unmarshalCases, unmarshalCase{
ptr: (*[]string)(nil),
input: "null",
}, unmarshalCase{
ptr: (*[]string)(nil),
input: "[]",
})
}