mirror of
https://github.com/json-iterator/go.git
synced 2024-11-24 08:22:14 +02:00
#26 do not enforce pointer as optional
This commit is contained in:
parent
7e046e6aa7
commit
fc44cb2d91
@ -108,8 +108,11 @@ func (iter *Iterator) readObjectStart() bool {
|
||||
}
|
||||
iter.unreadByte()
|
||||
return true
|
||||
} else if c == 'n' {
|
||||
iter.skipFixedBytes(3)
|
||||
return false
|
||||
}
|
||||
iter.reportError("readObjectStart", "expect { ")
|
||||
iter.reportError("readObjectStart", "expect { or n")
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ func Test_encode_null(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_decode_null_object(t *testing.T) {
|
||||
should := require.New(t)
|
||||
iter := ParseString(`[null,"a"]`)
|
||||
iter.ReadArray()
|
||||
if iter.ReadObject() != "" {
|
||||
@ -48,6 +49,12 @@ func Test_decode_null_object(t *testing.T) {
|
||||
if iter.ReadString() != "a" {
|
||||
t.FailNow()
|
||||
}
|
||||
type TestObject struct {
|
||||
Field string
|
||||
}
|
||||
objs := []TestObject{}
|
||||
should.Nil(UnmarshalFromString("[null]", &objs))
|
||||
should.Len(objs, 1)
|
||||
}
|
||||
|
||||
func Test_decode_null_array(t *testing.T) {
|
||||
@ -66,7 +73,7 @@ func Test_decode_null_string(t *testing.T) {
|
||||
should := require.New(t)
|
||||
iter := ParseString(`[null,"a"]`)
|
||||
should.True(iter.ReadArray())
|
||||
should.True(iter.ReadNil())
|
||||
should.Equal("", iter.ReadString())
|
||||
should.True(iter.ReadArray())
|
||||
should.Equal("a", iter.ReadString())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user