null

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2020 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package null provides performant nullable values for JSON serialization/deserialization

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type String

type String struct {
	Value  string
	Exists bool
}

String 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 FromString

func FromString(s string) String

FromString creates a non-null String. It is inlined by the compiler.

func (*String) IsNull

func (s *String) IsNull() bool

IsNull checks if a value is null

func (*String) MarshalJSON

func (s *String) MarshalJSON() ([]byte, error)

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 (*String) String

func (s *String) String() string

String implements fmt.Stringer interface It is inlined by the compiler.

func (*String) UnmarshalJSON

func (s *String) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL