1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00

#34 support More() and Buffered()

This commit is contained in:
Tao Wen
2017-06-02 16:00:12 +08:00
parent a7f992f0e1
commit 69b742e73a
2 changed files with 26 additions and 2 deletions

View File

@ -112,4 +112,13 @@ type AdaptedDecoder struct {
func (adapter *AdaptedDecoder) Decode(obj interface{}) error {
adapter.iter.ReadVal(obj)
return adapter.iter.Error
}
func (adapter *AdaptedDecoder) More() bool {
return adapter.iter.head != adapter.iter.tail
}
func (adapter *AdaptedDecoder) Buffered() io.Reader {
remaining := adapter.iter.buf[adapter.iter.head:adapter.iter.tail]
return bytes.NewReader(remaining)
}