jsonutil

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: MIT Imports: 8 Imported by: 25

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(bts []byte, ptr interface{}) error

Decode json bytes to data ptr.

func DecodeReader added in v0.4.3

func DecodeReader(r io.Reader, ptr interface{}) error

DecodeReader decode JSON from io reader.

func DecodeString added in v0.5.0

func DecodeString(str string, ptr interface{}) error

DecodeString json string to data ptr.

func Encode

func Encode(v interface{}) ([]byte, error)

Encode data to json bytes.

func EncodePretty added in v0.5.2

func EncodePretty(v interface{}) ([]byte, error)

EncodePretty encode pretty JSON data to json bytes.

func EncodeToWriter added in v0.5.0

func EncodeToWriter(v interface{}, w io.Writer) error

EncodeToWriter encode data to writer.

func EncodeUnescapeHTML added in v0.5.0

func EncodeUnescapeHTML(v interface{}) ([]byte, error)

EncodeUnescapeHTML data to json bytes. will close escape HTML

func Mapping added in v0.5.3

func Mapping(src, dst interface{}) error

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 Pretty

func Pretty(v interface{}) (string, error)

Pretty JSON string and return

func ReadFile

func ReadFile(filePath string, v interface{}) error

ReadFile Read JSON file data

func StripComments added in v0.1.3

func StripComments(src string) string

StripComments strip comments for a JSON string

func WriteFile

func WriteFile(filePath string, data interface{}) error

WriteFile write data to JSON file

Types

This section is empty.

Jump to

Keyboard shortcuts

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