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

Method Array

encode_array.go:62–81  ·  view source on GitHub ↗

Array adds an implementation of MarshalerJSONArray to be encoded, must be used inside a slice or array encoding (does not encode a key) value must implement Marshaler

(v MarshalerJSONArray)

Source from the content-addressed store, hash-verified

60// Array adds an implementation of MarshalerJSONArray to be encoded, must be used inside a slice or array encoding (does not encode a key)
61// value must implement Marshaler
62func (enc *Encoder) Array(v MarshalerJSONArray) {
63 if v.IsNil() {
64 enc.grow(3)
65 r := enc.getPreviousRune()
66 if r != '[' {
67 enc.writeByte(',')
68 }
69 enc.writeByte('[')
70 enc.writeByte(']')
71 return
72 }
73 enc.grow(100)
74 r := enc.getPreviousRune()
75 if r != '[' {
76 enc.writeByte(',')
77 }
78 enc.writeByte('[')
79 v.MarshalJSONArray(enc)
80 enc.writeByte(']')
81}
82
83// ArrayOmitEmpty adds an array or slice to be encoded, must be used inside a slice or array encoding (does not encode a key)
84// value must implement Marshaler

Callers 5

SliceStringMethod · 0.95
SliceIntMethod · 0.95
SliceFloat64Method · 0.95
SliceBoolMethod · 0.95
AddArrayMethod · 0.95

Calls 5

growMethod · 0.95
getPreviousRuneMethod · 0.95
writeByteMethod · 0.95
IsNilMethod · 0.65
MarshalJSONArrayMethod · 0.65

Tested by

no test coverage detected