...

Source file src/github.com/launchdarkly/go-jsonstream/v3/jwriter/writer_marshal.go

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

     1  package jwriter
     2  
     3  // MarshalJSONWithWriter is a convenience method for implementing json.Marshaler to marshal to a
     4  // byte slice with the default TokenWriter implementation.
     5  func MarshalJSONWithWriter(writable Writable) ([]byte, error) {
     6  	w := NewWriter()
     7  	w.tw.Grow(1000)
     8  	writable.WriteToJSONWriter(&w)
     9  	if err := w.Error(); err != nil {
    10  		return nil, err
    11  	}
    12  	return w.Bytes(), nil
    13  }
    14  

View as plain text