1
0
mirror of https://github.com/json-iterator/go.git synced 2024-11-24 08:22:14 +02:00

fix #261 should load from reader

This commit is contained in:
Tao Wen 2018-04-18 16:11:14 +08:00
parent f89479f5c0
commit a949c42748
2 changed files with 10 additions and 1 deletions

View File

@ -77,7 +77,10 @@ func (adapter *Decoder) Decode(obj interface{}) error {
// More is there more?
func (adapter *Decoder) More() bool {
return adapter.iter.head != adapter.iter.tail
if adapter.iter.head != adapter.iter.tail {
return true
}
return adapter.iter.loadMore()
}
// Buffered remaining buffer

View File

@ -56,3 +56,9 @@ func Test_use_number(t *testing.T) {
should.Nil(decoder2.Decode(&obj2))
should.Equal(json.Number("123"), obj2)
}
func Test_decoder_more(t *testing.T) {
should := require.New(t)
decoder := jsoniter.NewDecoder(bytes.NewBufferString("abcde"))
should.True(decoder.More())
}