json

package
v0.0.53 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: Apache-2.0 Imports: 7 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyStruct

func CopyStruct(originData, targetStruct any)

CopyStruct 通过json序列化/反序列化将origin struct复制给target struct 忽略任何错误

func CopyStructError

func CopyStructError(originData, targetStruct any) error

CopyStructError 通过json序列化/反序列化将origin struct复制给target struct 返回任何错误

func CopyStructPanic

func CopyStructPanic(originData, targetStruct any)

CopyStructPanic 通过json序列化/反序列化将origin struct复制给target struct 任何错误将触发panic

func GetBoolValue added in v0.0.44

func GetBoolValue(json, path string) (bool, bool)

GetBoolValue 获取指定json结构中的bool值

func GetFloatValue added in v0.0.44

func GetFloatValue(json, path string) (float64, bool)

GetFloatValue 获取指定json结构中的float值

func GetIntValue added in v0.0.44

func GetIntValue(json, path string) (int64, bool)

GetIntValue 获取指定json结构中的int值

func GetRawJson added in v0.0.44

func GetRawJson(json, path string) string

GetRawJson 获取指定路径的原始json字符串

func GetStringValue added in v0.0.44

func GetStringValue(json, path string) (string, bool)

GetStringValue 获取指定json结构中的字符串值

func GetUintValue added in v0.0.44

func GetUintValue(json, path string) (uint64, bool)

GetUintValue 获取指定json结构中的uint值

func GlobalWrapperSetting added in v0.0.29

func GlobalWrapperSetting(opt ...SetWrapperOption)

func ParseBytes added in v0.0.6

func ParseBytes(bytes []byte, any any)

ParseBytes 将byte数据转化成对象 忽略任何错误

func ParseBytesError added in v0.0.6

func ParseBytesError(bytes []byte, any any) error

ParseBytesError 将byte数据转化成对象 返回任何错误

func ParseBytesPanic added in v0.0.6

func ParseBytesPanic(bytes []byte, any any)

ParseBytesPanic 将byte数据转化成对象 任何错误将触发panic

func ParseJson

func ParseJson(jsonString string, any any)

ParseJson 转对象 忽略任何错误

func ParseJsonError

func ParseJsonError(jsonString string, any any) error

ParseJsonError 转对象 返回任何错误

func ParseJsonPanic

func ParseJsonPanic(jsonString string, any any)

ParseJsonPanic 转对象 任何错误将触发panic

func Time2Timestamp added in v0.0.30

func Time2Timestamp(time time.Time) ([]byte, error)

func Timestamp2Time added in v0.0.30

func Timestamp2Time(timestampBytes []byte) (time.Time, error)

func ToJson

func ToJson(any any) (json string)

ToJson 转json字符串 忽略任何错误

func ToJsonBytes

func ToJsonBytes(any any) (bytes []byte)

ToJsonBytes 转json字节 忽略任何错误

func ToJsonBytesError

func ToJsonBytesError(any any) ([]byte, error)

ToJsonBytesError 转json字节 返回任何错误

func ToJsonBytesPanic

func ToJsonBytesPanic(any any) (jsonBytes []byte)

ToJsonBytesPanic 转json字节 任何错误将触发panic

func ToJsonError

func ToJsonError(any any) (jsonString string, err error)

ToJsonError 转json字符串 返回任何错误

func ToJsonFormat

func ToJsonFormat(any any) (jsonFormat string)

ToJsonFormat 转json字符串并格式化输出 忽略任何错误

func ToJsonFormatError

func ToJsonFormatError(any any) (string, error)

ToJsonFormatError 转json字符串并格式化输出 返回任何错误

func ToJsonPanic

func ToJsonPanic(any any) (jsonString string)

ToJsonPanic 转json字符串 任何错误将触发panic

Types

type GJsonObject added in v0.0.44

type GJsonObject struct {
	// contains filtered or unexported fields
}

GJsonObject 结构体

func GetObject added in v0.0.44

func GetObject(json, path string) (*GJsonObject, bool)

GetObject 获取指定json结构中的对象

func (*GJsonObject) Get added in v0.0.44

func (g *GJsonObject) Get(jsonKey string) (*GJsonValue, bool)

Get 获取指定json结构中的值

func (*GJsonObject) GetArrayValue added in v0.0.44

func (g *GJsonObject) GetArrayValue(jsonKey string) ([]*GJsonValue, bool)

GetArrayValue 获取指定json结构中的数组

func (*GJsonObject) GetBoolValue added in v0.0.44

func (g *GJsonObject) GetBoolValue(jsonKey string) (bool, bool)

GetBoolValue 获取指定json结构中的bool值

func (*GJsonObject) GetFloatValue added in v0.0.44

func (g *GJsonObject) GetFloatValue(jsonKey string) (float64, bool)

GetFloatValue 获取指定json结构中的float值

func (*GJsonObject) GetIntValue added in v0.0.44

func (g *GJsonObject) GetIntValue(jsonKey string) (int64, bool)

GetIntValue 获取指定json结构中的int值

func (*GJsonObject) GetObject added in v0.0.44

func (g *GJsonObject) GetObject(jsonKey string) (*GJsonObject, bool)

GetObject 获取指定json结构中的对象

func (*GJsonObject) GetRawJson added in v0.0.44

func (g *GJsonObject) GetRawJson(jsonKey string) (string, bool)

GetRawJson 获取指定json结构中的原始json字符串

func (*GJsonObject) GetStringValue added in v0.0.44

func (g *GJsonObject) GetStringValue(jsonKey string) (string, bool)

GetStringValue 获取指定json结构中的字符串值

func (*GJsonObject) GetUintValue added in v0.0.44

func (g *GJsonObject) GetUintValue(jsonKey string) (uint64, bool)

GetUintValue 获取指定json结构中的uint值

type GJsonValue added in v0.0.44

type GJsonValue struct {
	// contains filtered or unexported fields
}

GJsonValue 结构体

func GetArrayValue added in v0.0.44

func GetArrayValue(json, path string) ([]*GJsonValue, bool)

GetArrayValue 获取指定json结构中的数组

func NewGJson added in v0.0.44

func NewGJson(json string) *GJsonValue

NewGJson 创建一个GJsonValue

func NewGJsonBytes added in v0.0.44

func NewGJsonBytes(json []byte) *GJsonValue

NewGJsonBytes 创建一个GJsonValue

func (*GJsonValue) ArrayValue added in v0.0.44

func (g *GJsonValue) ArrayValue() ([]*GJsonValue, bool)

ArrayValue 获取指定json结构中的数组

func (*GJsonValue) BoolValue added in v0.0.44

func (g *GJsonValue) BoolValue() (bool, bool)

BoolValue 获取指定json结构中的bool值

func (*GJsonValue) FloatValue added in v0.0.44

func (g *GJsonValue) FloatValue() (float64, bool)

FloatValue 获取指定json结构中的float值

func (*GJsonValue) Foreach added in v0.0.53

func (g *GJsonValue) Foreach(fn func(key, value gjson.Result) bool)

func (*GJsonValue) GJsonObjectValue added in v0.0.44

func (g *GJsonValue) GJsonObjectValue() (*GJsonObject, bool)

GJsonObjectValue 获取指定json结构中的对象

func (*GJsonValue) Get added in v0.0.44

func (g *GJsonValue) Get(path string) *GJsonValue

Get 获取指定json结构中的值

func (*GJsonValue) IntValue added in v0.0.44

func (g *GJsonValue) IntValue() (int64, bool)

IntValue 获取指定json结构中的int值

func (*GJsonValue) RawJsonString added in v0.0.44

func (g *GJsonValue) RawJsonString() string

RawJsonString 获取指定json结构中的原始json字符串

func (*GJsonValue) StringValue added in v0.0.44

func (g *GJsonValue) StringValue() (string, bool)

StringValue 获取指定json结构中的字符串值

func (*GJsonValue) UintValue added in v0.0.44

func (g *GJsonValue) UintValue() (uint64, bool)

UintValue 获取指定json结构中的uint值

type SetWrapperOption added in v0.0.29

type SetWrapperOption func(*TypeWrapperOptions)

type TimeStampType added in v0.0.29

type TimeStampType int
const (
	// TimestampTypeMilli 时间戳类型 毫秒级别
	TimestampTypeMilli TimeStampType = 0
	// TimestampTypeSecond 时间戳类型 秒级别
	TimestampTypeSecond TimeStampType = 1
)

type Timestamp added in v0.0.29

type Timestamp struct {
	time.Time
}

func (Timestamp) MarshalJSON added in v0.0.29

func (t Timestamp) MarshalJSON() ([]byte, error)

func (*Timestamp) UnmarshalJSON added in v0.0.29

func (t *Timestamp) UnmarshalJSON(data []byte) error

type TypeWrapperOptions added in v0.0.29

type TypeWrapperOptions struct {
	// 序列化/反序列化 时间戳类型
	TimestampType TimeStampType
}

Jump to

Keyboard shortcuts

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