diff --git a/feature_adapter.go b/feature_adapter.go index b860bf1..e0ab948 100644 --- a/feature_adapter.go +++ b/feature_adapter.go @@ -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 diff --git a/feature_config.go b/feature_config.go index c08515e..78a2ce1 100644 --- a/feature_config.go +++ b/feature_config.go @@ -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} }