json

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

JSON processing.

Index

Constants

This section is empty.

Variables

View Source
var (
	NamingStrategyTranslate = func(v string) string { return v }
)

Functions

func ConvertAnySlice added in v0.4.13

func ConvertAnySlice[T any](v []any) ([]T, error)

Convert []any to []T through json serialization/deserialization.

func ConvertAnySliceWithStr added in v0.4.13

func ConvertAnySliceWithStr[T any](v []any) ([]pair.Pair[string, T], error)

Convert []any to []T through json serialization/deserialization.

func CustomSWriteJson

func CustomSWriteJson(c jsoniter.API, body any) (string, error)

Write json as string using customized jsoniter.Config.

func DecodeJson

func DecodeJson(reader io.Reader, ptr any) error

Decode json.

func EncodeJson

func EncodeJson(writer io.Writer, body any) error

Encode json.

func EscapeString

func EscapeString(s string) string

func Indent

func Indent(b []byte) string

func IsValidJson

func IsValidJson(s []byte) bool

func IsValidJsonStr

func IsValidJsonStr(s string) bool

func LowercaseNamingStrategy

func LowercaseNamingStrategy(name string) string

Change first rune to lower case.

func Marshal

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

Write json as bytes.

func ParseJson

func ParseJson(body []byte, ptr any) error

Parse json bytes.

func ParseJsonAs

func ParseJsonAs[T any](body []byte) (T, error)

Parse json bytes.

func SIndent

func SIndent(b string) string

func SParseJson

func SParseJson(body string, ptr any) error

Parse json string.

func SParseJsonAs

func SParseJsonAs[T any](body string) (T, error)

Parse json bytes.

func SWriteIndent

func SWriteIndent(body any) (string, error)

func SWriteJson

func SWriteJson(body any) (string, error)

Write json as string.

func TrySWriteIndent added in v0.4.12

func TrySWriteIndent(body any) string

func TrySWriteJson

func TrySWriteJson(body any) string

Write json as string.

func Unmarshal

func Unmarshal(body []byte, ptr any) error

Write json as bytes.

func WriteJson

func WriteJson(body any) ([]byte, error)

Write json as bytes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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