Documentation ¶
Overview ¶
nolint: dupl
nolint: dupl
nolint: dupl
nolint: dupl
nolint: dupl
nolint: dupl
nolint: dupl
Package null provides performant nullable values for JSON serialization/deserialization
nolint: dupl
nolint: dupl
nolint: dupl
nolint: dupl
Index ¶
- func NonEmptyEncoder() jsoniter.ValEncoder
- func RegisterValidators(validate *validator.Validate)
- func StringDecoder() jsoniter.ValDecoder
- func StringEncoder() jsoniter.ValEncoder
- func ValidateNullType(val reflect.Value) interface{}
- type Bool
- type Float32
- type Float64
- type Int16
- type Int32
- type Int64
- type Int8
- type NonEmpty
- type String
- type Uint16
- type Uint32
- type Uint64
- type Uint8
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NonEmptyEncoder ¶
func NonEmptyEncoder() jsoniter.ValEncoder
func RegisterValidators ¶
func RegisterValidators(validate *validator.Validate)
RegisterValidators registers custom type validators for null values
func StringDecoder ¶
func StringDecoder() jsoniter.ValDecoder
func StringEncoder ¶
func StringEncoder() jsoniter.ValEncoder
func ValidateNullType ¶
Types ¶
type Bool ¶
Bool represents a nullable boolean value. It accepts 1, "0", "t", "T", "TRUE", true, "true", "True", 0, "0", "f", "F", "FALSE", false, "false", "False". It is using the same convensions as `stronv.ParseBool` https://golang.org/pkg/strconv/#ParseBool.
func (Bool) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
func (*Bool) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface. It decodes Bool value s from string, number or null JSON input using strconv.ParseBool.
type Float32 ¶
func FromFloat32 ¶
FromFloat32 creates a non-null Float32. It is inlined by the compiler.
func (Float32) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
func (*Float32) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface. It decodes Float32 value s from string, number or null JSON input.
type Float64 ¶
func FromFloat64 ¶
FromFloat64 creates a non-null Float64. It is inlined by the compiler.
func (Float64) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
func (*Float64) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface. It decodes Float64 value s from string, number or null JSON input.
type Int16 ¶
Int16 represents a nullable int16 value. It parses both string an number JSON values.
func (Int16) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
func (*Int16) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface. It decodes Int16 value s from string, number or null JSON input.
type Int32 ¶
Int32 represents a nullable int32 value. It parses both string an number JSON values.
func (Int32) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
func (*Int32) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface. It decodes Int32 value s from string, number or null JSON input.
type Int64 ¶
Int64 represents a nullable int64 value. It parses both string an number JSON values.
func (Int64) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
func (*Int64) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface. It decodes Int64 value s from string, number or null JSON input.
type Int8 ¶
Int8 represents a nullable int8 value. It parses both string an number JSON values.
func (Int8) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
func (*Int8) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface. It decodes Int8 value s from string, number or null JSON input.
type NonEmpty ¶
type NonEmpty String
NonEmpty is a nullable string value It's useful to handle string JSON values that could be `null` in the incoming log JSON. It's `omitempty` behavior when used with `jsoniter` is to omit both `""` and `null` in the output
func (*NonEmpty) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface WARNING: Since `json` package has no method of modifying `omitempty` behavior, the empty values (`null`, `""`) cannot be omitted when using `json.Marshal`. To omit a `null` or empty string we need to use `jsoniter.Marshal`.
func (*NonEmpty) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface
type String ¶
String is a nullable string value that retains empty string in the input It's useful to handle string JSON values that could be `null` in the incoming log JSON. It's `omitempty` behavior when used with `jsoniter` is to only omit `null` in the output
func FromString ¶
FromString creates a non-null String. It is inlined by the compiler.
func (*String) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface
func (*String) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface
type Uint16 ¶
Uint16 represents a nullable uint16 value. It parses both string an number JSON values.
func FromUint16 ¶
FromUint16 creates a non-null Uint16. It is inlined by the compiler.
func (Uint16) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
func (*Uint16) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface. It decodes Int16 value s from string, number or null JSON input.
type Uint32 ¶
Uint32 represents a nullable uint32 value. It parses both string an number JSON values.
func FromUint32 ¶
FromUint32 creates a non-null Uint32. It is inlined by the compiler.
func (Uint32) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
func (*Uint32) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface. It decodes Int32 value s from string, number or null JSON input.
type Uint64 ¶
Uint64 represents a nullable uint64 value. It parses both string an number JSON values.
func FromUint64 ¶
FromUint64 creates a non-null Uint64. It is inlined by the compiler.
func (Uint64) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
func (*Uint64) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface. It decodes Int64 value s from string, number or null JSON input.
type Uint8 ¶
Uint8 represents a nullable uint8 value. It parses both string an number JSON values.
func (Uint8) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
func (*Uint8) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface. It decodes Int8 value s from string, number or null JSON input.