Documentation
¶
Overview ¶
Package sdjson JSON工具库
Index ¶
- Variables
- func As[T any](v any) (T, bool)
- func AsBool(v any) (bool, bool)
- func AsBoolDef(v any, def bool) bool
- func AsDef[T any](v any, def T) T
- func AsFloat[T float32 | float64](v any) (T, bool)
- func AsFloatDef[T float32 | float64](v any, def T) T
- func AsInt[T int | int8 | int16 | int32 | int64](v any) (T, bool)
- func AsIntDef[T int | int8 | int16 | int32 | int64](v any, def T) T
- func AsString(v any) (string, bool)
- func AsStringDef(v any, def string) string
- func AsUint[T uint | uint8 | uint16 | uint32 | uint64](v any) (T, bool)
- func AsUintDef[T uint | uint8 | uint16 | uint32 | uint64](v any, def T) T
- func MarshalBase64(v any) (string, error)
- func MarshalBase64Def(v any, def string) string
- func MarshalIndentString(v any, prefix, indent string) (string, error)
- func MarshalIndentStringDef(v any, prefix, indent, def string) string
- func MarshalPretty(v any) string
- func MarshalString(v any) (string, error)
- func MarshalStringDef(v any, def string) string
- func ObjectToStruct[T any](o Object) (T, error)
- func Register(c Converter)
- func To[T any](v any) (T, bool)
- func ToBool(v any) (bool, bool)
- func ToFloat[T float32 | float64](v any) (T, bool)
- func ToInt[T int | int8 | int16 | int32 | int64](v any) (T, bool)
- func ToPrimitive(v any) (any, error)
- func ToPrimitiveDef(v any, def any) any
- func ToString(v any) (string, bool)
- func ToUint[T uint | uint8 | uint16 | uint32 | uint64](v any) (T, bool)
- func TryPrimitive(v any) any
- func UnmarshalBase64(b64 string, v any) error
- func UnmarshalBase64Typed[T any](b64 string) (T, error)
- func UnmarshalBase64TypedDef[T any](b64 string, def T) T
- func UnmarshalString(s string, v any) error
- func UnmarshalStringTyped[T any](j string) (T, error)
- func UnmarshalStringTypedDef[T any](j string, def T) T
- func UnmarshalTyped[T any](raw []byte) (T, error)
- func UnmarshalTypedDef[T any](raw []byte, def T) T
- type Array
- type Converter
- type Object
- type Value
- func (v Value) As(ptr any) bool
- func (v Value) AsArray() (Array, bool)
- func (v Value) AsArrayDef(def Array) Array
- func (v Value) AsBool() (bool, bool)
- func (v Value) AsBoolDef(def bool) bool
- func (v Value) AsFloat32() (float32, bool)
- func (v Value) AsFloat32Def(def float32) float32
- func (v Value) AsFloat64() (float64, bool)
- func (v Value) AsFloat64Def(def float64) float64
- func (v Value) AsInt() (int, bool)
- func (v Value) AsInt16() (int16, bool)
- func (v Value) AsInt16Def(def int16) int16
- func (v Value) AsInt32() (int32, bool)
- func (v Value) AsInt32Def(def int32) int32
- func (v Value) AsInt64() (int64, bool)
- func (v Value) AsInt64Def(def int64) int64
- func (v Value) AsInt8() (int8, bool)
- func (v Value) AsInt8Def(def int8) int8
- func (v Value) AsIntDef(def int) int
- func (v Value) AsObject() (Object, bool)
- func (v Value) AsObjectDef(def Object) Object
- func (v Value) AsString() (string, bool)
- func (v Value) AsStringDef(def string) string
- func (v Value) AsUint() (uint, bool)
- func (v Value) AsUint16() (uint16, bool)
- func (v Value) AsUint16Def(def uint16) uint16
- func (v Value) AsUint32() (uint32, bool)
- func (v Value) AsUint32Def(def uint32) uint32
- func (v Value) AsUint64() (uint64, bool)
- func (v Value) AsUint64Def(def uint64) uint64
- func (v Value) AsUint8() (uint8, bool)
- func (v Value) AsUint8Def(def uint8) uint8
- func (v Value) AsUintDef(def uint) uint
- func (v Value) At(i int) Value
- func (v Value) Get(k string) Value
- func (v Value) Gets(k string, subKeys ...string) Value
- func (v Value) Interface() any
- func (v Value) IsNil() bool
- func (v Value) MarshalJSON() ([]byte, error)
- func (v Value) To(ptr any) bool
- func (v Value) ToArray() (Array, bool)
- func (v Value) ToBool() (bool, bool)
- func (v Value) ToFloat32() (float32, bool)
- func (v Value) ToFloat64() (float64, bool)
- func (v Value) ToInt() (int, bool)
- func (v Value) ToInt16() (int16, bool)
- func (v Value) ToInt32() (int32, bool)
- func (v Value) ToInt64() (int64, bool)
- func (v Value) ToInt8() (int8, bool)
- func (v Value) ToObject() (Object, bool)
- func (v Value) ToString() (string, bool)
- func (v Value) ToUint() (uint, bool)
- func (v Value) ToUint16() (uint16, bool)
- func (v Value) ToUint32() (uint32, bool)
- func (v Value) ToUint64() (uint64, bool)
- func (v Value) ToUint8() (uint8, bool)
- func (v *Value) UnmarshalJSON(raw []byte) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Unmarshal = json.Unmarshal Marshal = json.Marshal MarshalIndent = json.MarshalIndent )
Functions ¶
func AsFloatDef ¶
func AsStringDef ¶
func MarshalBase64 ¶
func MarshalBase64Def ¶
func MarshalIndentStringDef ¶
func MarshalPretty ¶
func MarshalString ¶
func MarshalStringDef ¶
func ObjectToStruct ¶
func ToPrimitive ¶
func ToPrimitiveDef ¶
func TryPrimitive ¶
func UnmarshalBase64 ¶
func UnmarshalBase64Typed ¶
func UnmarshalBase64TypedDef ¶
func UnmarshalString ¶
func UnmarshalStringTyped ¶
func UnmarshalStringTypedDef ¶
func UnmarshalTyped ¶
func UnmarshalTypedDef ¶
Types ¶
type Converter ¶
type Converter interface { ToBool(v any, as bool) (bool, bool) ToString(v any, as bool) (string, bool) ToInt(v any, as bool) (int64, bool) ToUint(v any, as bool) (uint64, bool) ToFloat(v any, as bool) (float64, bool) ToObject(v any, as bool) (Object, bool) ToArray(v any, as bool) (Array, bool) ToAny(v any, as bool, ptr any) bool }
type Object ¶
func AsObjectDef ¶
func StructToObject ¶
func (Object) ShadowCopy ¶
func (Object) TryPrimitive ¶
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
func UnmarshalValue ¶
func UnmarshalValueString ¶
func (Value) AsArrayDef ¶
func (Value) AsFloat32Def ¶
func (Value) AsFloat64Def ¶
func (Value) AsInt16Def ¶
func (Value) AsInt32Def ¶
func (Value) AsInt64Def ¶
func (Value) AsObjectDef ¶
func (Value) AsStringDef ¶
func (Value) AsUint16Def ¶
func (Value) AsUint32Def ¶
func (Value) AsUint64Def ¶
func (Value) AsUint8Def ¶
func (Value) MarshalJSON ¶
func (*Value) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.