jsonutil

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package jsonutil provide some util functions for quick operate JSON data

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(bts []byte, ptr any) error

Decode json bytes to data ptr.

func DecodeReader

func DecodeReader(r io.Reader, ptr any) error

DecodeReader decode JSON from io reader.

func DecodeString

func DecodeString(str string, ptr any) error

DecodeString json string to data ptr.

func Encode

func Encode(v any) ([]byte, error)

Encode data to json bytes.

func EncodePretty

func EncodePretty(v any) ([]byte, error)

EncodePretty encode pretty JSON data to json bytes.

func EncodeToWriter

func EncodeToWriter(v any, w io.Writer) error

EncodeToWriter encode data to writer.

func EncodeUnescapeHTML

func EncodeUnescapeHTML(v any) ([]byte, error)

EncodeUnescapeHTML data to json bytes. will close escape HTML

func Mapping

func Mapping(src, dst any) 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 any) (string, error)

Pretty JSON string and return

func ReadFile

func ReadFile(filePath string, v any) error

ReadFile Read JSON file data

func StripComments

func StripComments(src string) string

StripComments strip comments for a JSON string

func WriteFile

func WriteFile(filePath string, data any) 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