Documentation ¶
Overview ¶
Package jsonutil provide some util functions for quick operate JSON data
Index ¶
- func Decode(bts []byte, ptr any) error
- func DecodeReader(r io.Reader, ptr any) error
- func DecodeString(str string, ptr any) error
- func Encode(v any) ([]byte, error)
- func EncodePretty(v any) ([]byte, error)
- func EncodeString(v any) (string, error)
- func EncodeToWriter(v any, w io.Writer) error
- func EncodeUnescapeHTML(v any) ([]byte, error)
- func IsArray(s string) bool
- func IsJSON(s string) bool
- func IsJSONFast(s string) bool
- func IsObject(s string) bool
- func Mapping(src, dst any) error
- func MustPretty(v any) string
- func MustString(v any) string
- func Pretty(v any) (string, error)
- func ReadFile(filePath string, v any) error
- func StripComments(src string) string
- func WriteFile(filePath string, data any) error
- func WritePretty(filePath string, data any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeReader ¶ added in v0.4.3
DecodeReader decode JSON from io reader.
func DecodeString ¶ added in v0.5.0
DecodeString json string to data ptr.
func EncodePretty ¶ added in v0.5.2
EncodePretty encode data to pretty JSON bytes.
func EncodeString ¶ added in v0.6.13
EncodeString encode data to JSON string.
func EncodeToWriter ¶ added in v0.5.0
EncodeToWriter encode data to json and write to writer.
func EncodeUnescapeHTML ¶ added in v0.5.0
EncodeUnescapeHTML data to json bytes. will close escape HTML
func IsJSONFast ¶ added in v0.6.9
IsJSONFast simple and fast check input is valid JSON array or object.
func Mapping ¶ added in v0.5.3
Mapping src data(map,struct) to dst struct use json tags.
On src, dst both is struct, equivalent to merging two structures (src should be a subset of dsc)
func MustPretty ¶ added in v0.6.13
MustPretty data to JSON string, will panic on error
func MustString ¶ added in v0.6.13
MustString encode data to json string, will panic on error
func StripComments ¶ added in v0.1.3
StripComments strip comments for a JSON string
func WritePretty ¶ added in v0.6.8
WritePretty write pretty data to JSON file
Types ¶
This section is empty.