mirror of
https://github.com/json-iterator/go.git
synced 2025-04-14 11:18:49 +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()
|
iter.unreadByte()
|
||||||
return true
|
return true
|
||||||
|
} else if c == 'n' {
|
||||||
|
iter.skipFixedBytes(3)
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
iter.reportError("readObjectStart", "expect { ")
|
iter.reportError("readObjectStart", "expect { or n")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ func Test_encode_null(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test_decode_null_object(t *testing.T) {
|
func Test_decode_null_object(t *testing.T) {
|
||||||
|
should := require.New(t)
|
||||||
iter := ParseString(`[null,"a"]`)
|
iter := ParseString(`[null,"a"]`)
|
||||||
iter.ReadArray()
|
iter.ReadArray()
|
||||||
if iter.ReadObject() != "" {
|
if iter.ReadObject() != "" {
|
||||||
@ -48,6 +49,12 @@ func Test_decode_null_object(t *testing.T) {
|
|||||||
if iter.ReadString() != "a" {
|
if iter.ReadString() != "a" {
|
||||||
t.FailNow()
|
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) {
|
func Test_decode_null_array(t *testing.T) {
|
||||||
@ -66,7 +73,7 @@ func Test_decode_null_string(t *testing.T) {
|
|||||||
should := require.New(t)
|
should := require.New(t)
|
||||||
iter := ParseString(`[null,"a"]`)
|
iter := ParseString(`[null,"a"]`)
|
||||||
should.True(iter.ReadArray())
|
should.True(iter.ReadArray())
|
||||||
should.True(iter.ReadNil())
|
should.Equal("", iter.ReadString())
|
||||||
should.True(iter.ReadArray())
|
should.True(iter.ReadArray())
|
||||||
should.Equal("a", iter.ReadString())
|
should.Equal("a", iter.ReadString())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user