Documentation ¶
Overview ¶
Package zjson provides functions for working with JSON.
Index ¶
- func Indent(data []byte, v any, prefix, indent string) ([]byte, error)
- func IndentString(data []byte, v any, prefix, indent string) (string, error)
- func MustIndent(data []byte, v any, prefix, indent string) []byte
- func MustIndentString(data []byte, v any, prefix, indent string) string
- func MustMarshal(v any) []byte
- func MustMarshalIndent(v any, prefix, indent string) []byte
- func MustMarshalIndentString(v any, prefix, indent string) string
- func MustMarshalString(v any) string
- func MustUnmarshal(data []byte, v any)
- func MustUnmarshalTo(data []byte, target reflect.Type) any
- func UnmarshalTo(data []byte, target reflect.Type) (any, error)
- type Int
- type Timestamp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Indent ¶
Indent a json string by unmarshalling it and marshalling it with MarshalIndent.
The data will be unmarshalled in to v, which must be a pointer. Example:
Indent(`{"a": "b"}`, &map[string]string{}, "", " ")
func IndentString ¶
IndentString is like Indent, but returns a string.
func MustIndent ¶
MustIndent behaves like Indent but will panic on errors.
func MustIndentString ¶
MustIndentString is like MustIndent, but returns a string.
func MustMarshal ¶
MustMarshal behaves like json.Marshal but will panic on errors.
func MustMarshalIndent ¶
MustMarshalIndent behaves like json.MarshalIndent but will panic on errors.
func MustMarshalIndentString ¶
MustMarshalIndentString is like MustMarshalIndent, but returns a string.
func MustMarshalString ¶
MustMarshalString is like MustMarshal, but returns a string.
func MustUnmarshal ¶
MustUnmarshal behaves like json.Unmarshal but will panic on errors.
func MustUnmarshalTo ¶
MustUnmarshalTo behaves like UnmarshalTo but will panic on errors.
Types ¶
type Int ¶
type Int int64
Int for APIs that return numbers as strings.
func (*Int) UnmarshalJSON ¶
Unmarshal a string timestamp as an int.
type Timestamp ¶
Timestamp for APIs that return dates as a numeric Unix timestamp.
func (*Timestamp) UnmarshalJSON ¶
Unmarshal a Unix timestamp as a date.