Documentation
¶
Overview ¶
Package json provides a high-performance JSON encoder/decoder based on jsoniter.
It extends the standard library with:
- Custom time.Time formatting (RFC3339 with milliseconds)
- Automatic camelCase conversion for struct field names
- Full API compatibility with encoding/json
This package is safe for concurrent use by multiple goroutines.
Index ¶
Constants ¶
const (
FullDateFormat = "2006-01-02T15:04:05.999Z07:00"
)
FullDateFormat is the default layout for time.Time serialization.
It uses RFC3339 with millisecond precision: "2006-01-02T15:04:05.999Z07:00"
Variables ¶
This section is empty.
Functions ¶
func EncodeInto ¶
EncodeInto encodes a value into a writer, appending a newline.
This is an optimized function for line-delimited JSON (e.g., NDJSON).
func Marshal ¶
Marshal returns the JSON encoding of v.
It uses the default jsoniter configuration with time formatting and camelCase field naming.
func NewDecoder ¶
NewDecoder returns a new decoder that reads from r.
func NewEncoder ¶
NewEncoder returns a new encoder that writes to w.
Types ¶
type RawMessage ¶
type RawMessage = json.RawMessage
RawMessage is a raw encoded JSON value. It implements Marshaler and Unmarshaler and can be used to delay JSON decoding or precompute a JSON encoding. It is an alias for encoding/json.RawMessage.
type TimeCodec ¶
type TimeCodec struct {
// contains filtered or unexported fields
}
TimeCodec is a jsoniter extension for custom time.Time encoding and decoding.
It formats time values using a configurable layout string.
func NewTimeCodec ¶
NewTimeCodec returns a new TimeCodec with the specified format layout.
The format string follows Go's time.Parse conventions (see time.Layout).
func (*TimeCodec) Decode ¶
Decode parses a JSON string into a time.Time value.
It reports an error to the iterator if the string cannot be parsed.