mjson

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IndentJson

func IndentJson(data any) string

将任意 JSON-able 数据转换为缩进格式的 JSON 字符串。 错误时返回 "{}"。

func Marshal added in v0.3.1

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

将结构体转为 JSON 字节切片。

func PrintAny

func PrintAny(data any) string

打印任意 JSON-able 数据的缩进格式的 JSON 字符串,并返回该字符串。

func ToByte

func ToByte(data any) ([]byte, error)

将任意数据转换为 JSON 字节切片。 JSON-able 包括结构体、map、切片等。 错误时返回非 nil 错误。

func ToMap

func ToMap(val any) (resData map[string]any, resErr error)

将任意 JSON-able 数据转换为 map[string]any。

func ToMapStr added in v0.1.4

func ToMapStr(val any) (resData map[string]string, resErr error)

将任意 JSON-able 数据转换为 map[string]string。

func ToStr

func ToStr(data any) string

将任意 JSON-able 数据转换为 JSON 字符串。 错误时返回 "{}"。

func Unmarshal added in v0.3.1

func Unmarshal(data []byte, v any) error

将 JSON 字节切片解析到结构体中。

Types

This section is empty.

Jump to

Keyboard shortcuts

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