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:
parent
404d90796f
commit
ea6403326b
@ -1,11 +1,8 @@
|
|||||||
package jsoniter
|
package jsoniter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
|
||||||
"unsafe"
|
"unsafe"
|
||||||
"github.com/v2pro/plz/reflect2"
|
"github.com/v2pro/plz/reflect2"
|
||||||
)
|
)
|
||||||
|
@ -78,7 +78,7 @@ func (decoder *sliceDecoder) doDecode(ptr unsafe.Pointer, iter *Iterator) {
|
|||||||
}
|
}
|
||||||
c = iter.nextToken()
|
c = iter.nextToken()
|
||||||
if c == ']' {
|
if c == ']' {
|
||||||
sliceType.Set(ptr, sliceType.UnsafeNew())
|
sliceType.UnsafeSet(ptr, sliceType.UnsafeMakeSlice(0, 0))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
iter.unreadByte()
|
iter.unreadByte()
|
||||||
|
@ -325,27 +325,27 @@ func structFields1To11() {
|
|||||||
Field9 string
|
Field9 string
|
||||||
})(nil),
|
})(nil),
|
||||||
(*struct {
|
(*struct {
|
||||||
Field1 string
|
Field1 string
|
||||||
Field2 string
|
Field2 string
|
||||||
Field3 string
|
Field3 string
|
||||||
Field4 string
|
Field4 string
|
||||||
Field5 string
|
Field5 string
|
||||||
Field6 string
|
Field6 string
|
||||||
Field7 string
|
Field7 string
|
||||||
Field8 string
|
Field8 string
|
||||||
Field9 string
|
Field9 string
|
||||||
Field10 string
|
Field10 string
|
||||||
})(nil),
|
})(nil),
|
||||||
(*struct {
|
(*struct {
|
||||||
Field1 string
|
Field1 string
|
||||||
Field2 string
|
Field2 string
|
||||||
Field3 string
|
Field3 string
|
||||||
Field4 string
|
Field4 string
|
||||||
Field5 string
|
Field5 string
|
||||||
Field6 string
|
Field6 string
|
||||||
Field7 string
|
Field7 string
|
||||||
Field8 string
|
Field8 string
|
||||||
Field9 string
|
Field9 string
|
||||||
Field10 string
|
Field10 string
|
||||||
Field11 string
|
Field11 string
|
||||||
})(nil),
|
})(nil),
|
||||||
|
@ -10,5 +10,8 @@ func init() {
|
|||||||
unmarshalCases = append(unmarshalCases, unmarshalCase{
|
unmarshalCases = append(unmarshalCases, unmarshalCase{
|
||||||
ptr: (*[]string)(nil),
|
ptr: (*[]string)(nil),
|
||||||
input: "null",
|
input: "null",
|
||||||
|
}, unmarshalCase{
|
||||||
|
ptr: (*[]string)(nil),
|
||||||
|
input: "[]",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user