Documentation
¶
Overview ¶
Package json provides high-performance JSON serialization with object pooling
Index ¶
- func GetBuffer() *bytes.Buffer
- func GetDecoder(r io.Reader) *gojson.Decoder
- func GetEncoder(w io.Writer) *gojson.Encoder
- func Marshal(v interface{}) ([]byte, error)
- func MarshalArray(values []interface{}) ([]byte, error)
- func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)
- func MarshalMultiple(values []interface{}, separator []byte) ([]byte, error)
- func MarshalRecords(records []*pool.Record, format string) ([]byte, error)
- func MarshalRecordsArray(records []*pool.Record) ([]byte, error)
- func MarshalRecordsLines(records []*pool.Record) ([]byte, error)
- func MarshalToBuffer(v interface{}) (*bytes.Buffer, error)
- func MarshalToWriter(w io.Writer, v interface{}) error
- func PutBuffer(buf *bytes.Buffer)
- func PutDecoder(dec *gojson.Decoder)
- func PutEncoder(enc *gojson.Encoder)
- func Unmarshal(data []byte, v interface{}) error
- type JSONPool
- type OptimizedJSONWriter
- type StreamingEncoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDecoder ¶
GetDecoder gets a pooled JSON decoder
func GetEncoder ¶
GetEncoder gets a pooled JSON encoder
func MarshalArray ¶
MarshalArray efficiently marshals a slice as a JSON array
func MarshalIndent ¶
MarshalIndent is a high-performance replacement for json.MarshalIndent
func MarshalMultiple ¶
MarshalMultiple efficiently marshals multiple objects to a single buffer
func MarshalRecords ¶
MarshalRecords efficiently marshals a slice of records
func MarshalRecordsArray ¶
MarshalRecordsArray marshals records as a JSON array
func MarshalRecordsLines ¶
MarshalRecordsLines marshals records as line-delimited JSON
func MarshalToBuffer ¶
MarshalToBuffer marshals v to a pooled buffer
func MarshalToWriter ¶
MarshalToWriter marshals v directly to a writer using pooled encoder
Types ¶
type JSONPool ¶
type JSONPool struct {
// contains filtered or unexported fields
}
JSONPool manages pooled JSON encoders and decoders
type OptimizedJSONWriter ¶
type OptimizedJSONWriter struct {
// contains filtered or unexported fields
}
OptimizedJSONWriter provides high-performance JSON writing with minimal allocations
func NewOptimizedJSONWriter ¶
func NewOptimizedJSONWriter(initialSize int) *OptimizedJSONWriter
NewOptimizedJSONWriter creates a new optimized JSON writer
func (*OptimizedJSONWriter) Bytes ¶
func (w *OptimizedJSONWriter) Bytes() []byte
Bytes returns the accumulated JSON bytes
func (*OptimizedJSONWriter) Reset ¶
func (w *OptimizedJSONWriter) Reset()
Reset resets the writer for reuse
func (*OptimizedJSONWriter) WriteField ¶
func (w *OptimizedJSONWriter) WriteField(key string, value interface{}) error
WriteField efficiently writes a JSON field
type StreamingEncoder ¶
type StreamingEncoder struct {
// contains filtered or unexported fields
}
StreamingEncoder provides efficient streaming JSON encoding
func NewStreamingEncoder ¶
func NewStreamingEncoder(w io.Writer, isArray bool) *StreamingEncoder
NewStreamingEncoder creates a new streaming encoder
func (*StreamingEncoder) Close ¶
func (se *StreamingEncoder) Close() error
Close finalizes the encoding
func (*StreamingEncoder) Encode ¶
func (se *StreamingEncoder) Encode(v interface{}) error
Encode encodes a single value
func (*StreamingEncoder) SetPretty ¶
func (se *StreamingEncoder) SetPretty(pretty bool, indent string)
SetPretty enables pretty printing