MCPcopy
hub / github.com/pquerna/ffjson / Encode

Method Encode

ffjson/encoder.go:58–72  ·  view source on GitHub ↗

Encode the data in the supplied value to the stream given on creation. When the function returns the output has been written to the stream.

(v interface{})

Source from the content-addressed store, hash-verified

56// When the function returns the output has been
57// written to the stream.
58func (e *Encoder) Encode(v interface{}) error {
59 f, ok := v.(marshalerFaster)
60 if ok {
61 e.buf.Reset()
62 err := f.MarshalJSONBuf(&e.buf)
63 if err != nil {
64 return err
65 }
66
67 _, err = io.Copy(e.w, &e.buf)
68 return err
69 }
70
71 return e.enc.Encode(v)
72}
73
74// EncodeFast will unmarshal the data if fast marshall is available.
75// This function can be used if you want to be sure the fast

Callers 5

TestMarshalEncoderFunction · 0.95
TestMarshalEncoderErrorFunction · 0.95
getXValueFunction · 0.95
EncodeFastMethod · 0.95

Calls 3

ResetMethod · 0.65
MarshalJSONBufMethod · 0.65
EncodeMethod · 0.65

Tested by 4

TestMarshalEncoderFunction · 0.76
TestMarshalEncoderErrorFunction · 0.76
getXValueFunction · 0.76