Documentation ¶
Index ¶
- Constants
- Variables
- func Equal(x, y io.Reader) (bool, error)
- func EqualBytes(x, y []byte) (bool, error)
- func EqualFiles(x, y string) (bool, error)
- func IndentBytes(data []byte, prefix, indent string) ([]byte, error)
- func IndentReader(r io.Reader, prefix, indent string) ([]byte, error)
- func MarshalBase64(v any) (string, error)
- func MarshalOrDefault(v any, def []byte) ([]byte, error)
- func MarshalSimple(v any, prefix, indent string) ([]byte, error)
- func MustMarshal(v any, embedError bool) []byte
- func MustMarshalIndent(v any, prefix, indent string, embedError bool) []byte
- func MustMarshalOrDefault(v any, def []byte) []byte
- func MustMarshalSimple(v any, prefix, indent string) []byte
- func MustMarshalString(v any, embedError bool) string
- func MustUnmarshal(b []byte, v any)
- func PrintReaderIndent(r io.Reader, prefix, indent string) ([]byte, error)
- func Unescape(b []byte, prefix, indent string) ([]byte, error)
- func UnmarshalAny(data, v any) error
- func UnmarshalFile(filename string, v any) ([]byte, error)
- func UnmarshalKeys(b []byte) ([]string, error)
- func UnmarshalKeysFile(filename string) ([]string, error)
- func UnmarshalMSI(data map[string]any, v any) error
- func UnmarshalReader(r io.Reader, v any) ([]byte, error)
- func UnmarshalStrict(b []byte, v any) error
- func WriteFile(filename string, v any, prefix, indent string, perm fs.FileMode) error
- func WriteFileIndentBytes(name string, data []byte, prefix, indent string, perm fs.FileMode) error
- type Bool
- type Int64
- type String
Constants ¶
const ( EmptyArray = "[]" EmptyObject = "{}" FileExt = ".json" )
Variables ¶
var ( MarshalPrefix = "" MarshalIndent = " " )
Functions ¶
func EqualBytes ¶ added in v0.50.0
func EqualFiles ¶ added in v0.50.0
func IndentBytes ¶ added in v0.41.5
IndentBytes converts a JSON byte array into a prettified byte array.
func IndentReader ¶ added in v0.41.6
IndentReader returns a byte slice of indented JSON given an `io.Reader`. It is useful to use with `http.Response.Body` which is an `io.ReadCloser`.
func MarshalBase64 ¶
func MarshalOrDefault ¶ added in v0.64.9
MarshalOrDefault returns the supplied default value in the event of an error. It also returns the error for processing.
func MustMarshal ¶
func MustMarshalIndent ¶
func MustMarshalOrDefault ¶ added in v0.64.9
func MustMarshalSimple ¶
func MustMarshalString ¶
func MustUnmarshal ¶ added in v0.37.5
func PrintReaderIndent ¶ added in v0.41.5
PrintReaderIndent returns an indented JSON byte array given an `io.Reader`.
func Unescape ¶ added in v0.64.2
Unescape is designed to unescape a stringified JSON. It is typically used after a stringified JSON has been embedded as a value in an wrapper JSON object. When using this, do not include outer quotes.
func UnmarshalAny ¶ added in v0.60.0
UnmarshalAny will unmarshal anything to `v`, including first marshalling anything that is not a byte array to a JSON byte array.
func UnmarshalKeys ¶ added in v0.63.2
func UnmarshalKeysFile ¶ added in v0.63.2
func UnmarshalStrict ¶ added in v0.39.4
UnmarshalStrict returns an error when the destination is a struct and the input contains object keys which do not match any non-ignored, exported fields in the destination.
Types ¶
type Bool ¶
type Bool bool
Bool implements a tolerant reader for `bool` type.
func (*Bool) UnmarshalJSON ¶
type Int64 ¶
type Int64 int64
Int64 implements a tolerant reader for `int64` type.