MCPcopy Create free account
hub / github.com/francoispqt/gojay / EncodeArray

Method EncodeArray

encode_array.go:4–15  ·  view source on GitHub ↗

EncodeArray encodes an implementation of MarshalerJSONArray to JSON

(v MarshalerJSONArray)

Source from the content-addressed store, hash-verified

2
3// EncodeArray encodes an implementation of MarshalerJSONArray to JSON
4func (enc *Encoder) EncodeArray(v MarshalerJSONArray) error {
5 if enc.isPooled == 1 {
6 panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
7 }
8 _, _ = enc.encodeArray(v)
9 _, err := enc.Write()
10 if err != nil {
11 enc.err = err
12 return err
13 }
14 return nil
15}
16func (enc *Encoder) encodeArray(v MarshalerJSONArray) ([]byte, error) {
17 enc.grow(200)
18 enc.writeByte('[')

Callers 5

EncodeMethod · 0.95
TestEncodingEmbeddedJSONFunction · 0.95
TestEncoderArrErrorsFunction · 0.95
TestEncodeObjectWithKeysFunction · 0.95

Calls 3

encodeArrayMethod · 0.95
WriteMethod · 0.95

Tested by 4

TestEncodingEmbeddedJSONFunction · 0.76
TestEncoderArrErrorsFunction · 0.76
TestEncodeObjectWithKeysFunction · 0.76