...

Source file src/github.com/launchdarkly/go-jsonstream/v3/jreader/reader_unmarshal.go

Documentation: github.com/launchdarkly/go-jsonstream/v3/jreader

     1  package jreader
     2  
     3  // UnmarshalJSONWithReader is a convenience method for implementing json.Marshaler to unmarshal from
     4  // a byte slice with the default TokenReader implementation. If an error occurs, it is converted to
     5  // the corresponding error type defined by the encoding/json package when applicable.
     6  //
     7  // This method will generally be less efficient than writing the exact same logic inline in a custom
     8  // UnmarshalJSON method for the object's specific type, because casting a pointer to an interface
     9  // (Readable) will force the object to be allocated on the heap if it was not already.
    10  func UnmarshalJSONWithReader(data []byte, readable Readable) error {
    11  	r := NewReader(data)
    12  	readable.ReadFromJSONReader(&r)
    13  	if err := r.Error(); err != nil {
    14  		return ToJSONError(err, readable)
    15  	}
    16  	return r.RequireEOF()
    17  }
    18  

View as plain text