Documentation ¶
Overview ¶
Package json provides configurable interfaces for JSON encoding and decoding.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Marshal marshals the given value into a JSON string. Marshal = json.Marshal // Unmarshal unmarshals the given JSON string into v. Unmarshal = json.Unmarshal // MarshalIndent marshals the given value into a JSON string with indentation. MarshalIndent = json.MarshalIndent // Indent is the indentation used in MarshalIndent. Indent = json.Indent // NewEncoder returns a new JSON encoder that writes to w. NewEncoder = json.NewEncoder // NewDecoder returns a new JSON decoder that reads from r. NewDecoder = json.NewDecoder )
View Source
var ( // EmptyStringBytes is a byte slice containing an empty JSON string. EmptyStringBytes = []byte(`""`) // NullBytes is a byte slice containing the JSON null literal. NullBytes = []byte("null") )
Functions ¶
Types ¶
type Nullable ¶
type Nullable[T any] struct { // contains filtered or unexported fields }
Nullable represents a nullable value. It gets serialized as either null or the value.
func NewOptional ¶
NewOptional returns a pointer to a new Nullable with t as the value.
func OptionalNull ¶
OptionalNull returns a pointer to a null Nullable.
func (Nullable[T]) MarshalJSON ¶
MarshalJSON implements the Marshaler interface.
func (*Nullable[T]) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaler interface.
type Unmarshaler ¶
type Unmarshaler = json.Unmarshaler
Unmarshaler is the interface implemented by types that can unmarshal a JSON description of themselves.
Click to show internal directories.
Click to hide internal directories.