gojson

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 4 Imported by: 48

README

Golang

📦 Golang Json

godoc goproxy.cn goreportcard.com deps.dev

安装

go get -v -u go.dtapp.net/gojson@v1.0.4

Documentation

Index

Constants

View Source
const Version = "1.0.4"

Variables

This section is empty.

Functions

func Encode

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

Encode 将 Go 数据结构编码为 JSON 字符串。

func IsValidJSON added in v1.0.2

func IsValidJSON(s string) bool

IsValidJSON 检查给定字符串是否为有效的 JSON 格式。

func JsonDecode

func JsonDecode(data string) (map[string]interface{}, error)

JsonDecode 将 JSON 字符串解析为 map 类型。

func JsonDecodeNoError

func JsonDecodeNoError(data string) map[string]interface{}

JsonDecodeNoError 同 JsonDecode,但忽略错误。

func JsonDecodesNoError

func JsonDecodesNoError(data string) []string

JsonDecodesNoError 将 JSON 字符串解析为字符串数组,忽略错误。

func JsonEncode

func JsonEncode(data interface{}) (string, error)

JsonEncode 将 Go 数据结构编码为 JSON 字符串。

func JsonEncodeNoError

func JsonEncodeNoError(data interface{}) string

JsonEncodeNoError 同 JsonEncode,但忽略错误。

func Marshal added in v1.0.2

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

Marshal 将 Go 数据结构转换为 JSON 字符串。

func MarshalToString

func MarshalToString(msg interface{}) (string, error)

MarshalToString 同 Encode 函数,将 Go 数据结构编码为 JSON 字符串。

func NewDecoder added in v1.0.3

func NewDecoder(r io.Reader) *json.Decoder

NewDecoder 创建一个新的 JSON 解码器(应返回解码器)。

func NewEncoder added in v1.0.3

func NewEncoder(w io.Writer) *json.Encoder

NewEncoder 创建一个新的 JSON 编码器(应返回编码器)。

func ParseQueryString added in v1.0.2

func ParseQueryString(input string) map[string]interface{}

ParseQueryString 解析 URL 查询字符串为 map 类型。

func Unmarshal added in v1.0.2

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

Unmarshal 将 JSON 字符串解析并映射到 Go 数据结构中。

func XmlDecodeNoError added in v1.0.4

func XmlDecodeNoError(b []byte) map[string]interface{}

XmlDecodeNoError xml字符串转结构体,不报错

func XmlEncodeNoError added in v1.0.4

func XmlEncodeNoError(data interface{}) string

XmlEncodeNoError 结构体转json字符串,不报错

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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