jsonutil

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

jsonutil

基于 json-iterator,提供 ToJSONString、ToJSONBytes、UnmarshalFromJSON、GetIntSliceFromJSON、 GetInt32SliceFromJSON 和 GetMapFromJSON。编解码失败时 panic,保持原公开行为。

ToJSONString(nil) 返回空字符串;ToJSONBytes(nil) 返回 JSON 的 null。 动态类型序列化可能使用依赖库的反射机制;其他工具子包不连带依赖此包。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInt32SliceFromJSON

func GetInt32SliceFromJSON(str string) []int32

func GetIntSliceFromJSON

func GetIntSliceFromJSON[T int | int8 | int32 | int64](str string) []T

func GetMapFromJSON

func GetMapFromJSON[T int | int32 | int64](str string, res *map[T]T)

func ToJSONBytes

func ToJSONBytes(v interface{}) []byte

ToJSONBytes marshals v as JSON and panics on a marshal error.

func ToJSONString

func ToJSONString(v interface{}) string

ToJSONString marshals v as JSON, returning an empty string for nil. A marshal error panics, matching the existing JSON helpers.

func UnmarshalFromJSON

func UnmarshalFromJSON(src string, data interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

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