code: func (d *YAMLOrJSONDecoder) Decode(into interface{}) error {
  	if d.decoder == nil {
  		buffer, origData, isJSON := GuessJSONStream(d.r, d.bufferSize)
  		if isJSON {
  			d.decoder = json.NewDecoder(buffer)
  			d.rawData = origData
  		} else {
  			d.decoder = NewYAMLToJSONDecoder(buffer)
  		}
  	}
  	err := d.decoder.Decode(into)
  	if jsonDecoder, ok := d.decoder.(*json.Decoder); ok {
  		if syntax, ok := err.(*json.SyntaxError); ok {
  			data, readErr := ioutil.ReadAll(jsonDecoder.Buffered())
  			if readErr != nil {
  				klog.V(4).Infof("reading stream failed: %v", readErr)
  			}
  			js := string(data)
  
  			// if contents from io.Reader are not complete,
  			// use the original raw data to prevent panic
  			if int64(len(js)) <= syntax.Offset {
  				js = string(d.rawData)
  			}
  
  			start := strings.LastIndex(js[:syntax.Offset], "\n") + 1
  			line := strings.Count(js[:start], "\n")
  			return JSONSyntaxError{
  				Line: line,
  				Err:  fmt.Errorf(syntax.Error()),
  			}
  		}
  	}
  	return err
  }
docs: // Decode unmarshals the next object from the underlying stream into the
  // provide object, or returns an error.