mirror of
https://github.com/json-iterator/go.git
synced 2025-04-04 21:34:16 +02:00
fix #215 lazy load more
This commit is contained in:
parent
e7a8aea845
commit
96fcb84835
@ -71,8 +71,10 @@ type Decoder struct {
|
||||
|
||||
// Decode decode JSON into interface{}
|
||||
func (adapter *Decoder) Decode(obj interface{}) error {
|
||||
if adapter.iter.Error == io.EOF {
|
||||
return io.EOF
|
||||
if adapter.iter.head == adapter.iter.tail && adapter.iter.reader != nil {
|
||||
if !adapter.iter.loadMore() {
|
||||
return io.EOF
|
||||
}
|
||||
}
|
||||
adapter.iter.ReadVal(obj)
|
||||
err := adapter.iter.Error
|
||||
|
@ -337,11 +337,6 @@ func (cfg *frozenConfig) NewEncoder(writer io.Writer) *Encoder {
|
||||
|
||||
func (cfg *frozenConfig) NewDecoder(reader io.Reader) *Decoder {
|
||||
iter := Parse(cfg, reader, 512)
|
||||
if reader != nil {
|
||||
if !iter.loadMore() {
|
||||
iter.Error = io.EOF
|
||||
}
|
||||
}
|
||||
return &Decoder{iter}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user