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 ¶
DecodeReader decode JSON from io reader.
func DecodeString ¶
DecodeString json string to data ptr.
func EncodePretty ¶
EncodePretty encode data to pretty JSON bytes.
func EncodeString ¶
EncodeString encode data to JSON string.
func EncodeToWriter ¶
EncodeToWriter encode data to json and write to writer.
func EncodeUnescapeHTML ¶
EncodeUnescapeHTML data to json bytes. will close escape HTML
func IsJSONFast ¶
IsJSONFast simple and fast check input is valid JSON array or object.
func Mapping ¶
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 MustString ¶
MustString encode data to json string, will panic on error
func StripComments ¶
StripComments strip comments for a JSON string
func WritePretty ¶
WritePretty write pretty data to JSON file
Types ¶
This section is empty.