json_rp

package module
v0.0.0-...-b2e263d Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	T_NIL = iota
	T_OBJECT
	T_OBJECT_PTR
	T_ARRAY
	T_ARRAY_PTR
	T_STRING
	T_BOOL
	T_NUMBER
	T_JSON_NUMBER
)

Variables

This section is empty.

Functions

func Marshal

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

func Unmarshal

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

Types

type Array

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

func NewArray

func NewArray() *Array

创建 Array

func (*Array) AddValue

func (r *Array) AddValue(value any)

添加值

func (*Array) EnumValue

func (r *Array) EnumValue(enum_func func(index int, value *Value))

遍历数组

func (*Array) GetValue

func (r *Array) GetValue(index int) *Value

获取Json值

func (*Array) Len

func (r *Array) Len() int

获取长度

func (*Array) ToBytes

func (r *Array) ToBytes() []byte

序列化成 []byte

func (*Array) ToSlice

func (r *Array) ToSlice() []any

To slice

func (*Array) ToString

func (r *Array) ToString() string

type Object

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

func NewObject

func NewObject() *Object

创建Object

func (*Object) EnumValue

func (r *Object) EnumValue(enum_func func(key string, value *Value))

遍历数组

func (*Object) GetValue

func (r *Object) GetValue(key string) *Value

获取Json值

func (*Object) HasValue

func (r *Object) HasValue(key string) bool

判断值是否存在

func (*Object) Len

func (r *Object) Len() int

获取长度

func (*Object) SetValue

func (r *Object) SetValue(key string, value interface{})

设置Json值

func (*Object) ToBytes

func (r *Object) ToBytes() []byte

序列化

func (*Object) ToString

func (r *Object) ToString() string

type Value

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

Json 值

func NewValue

func NewValue(value interface{}) *Value

创建 Value

func ParseFile

func ParseFile(filePath string) (*Value, error)

func ParseJson

func ParseJson(json_data []byte) (*Value, error)

解析Json

func (*Value) AsArray

func (r *Value) AsArray() *Array

func (*Value) AsFloat32

func (r *Value) AsFloat32() float32

func (*Value) AsFloat64

func (r *Value) AsFloat64() float64

func (*Value) AsInt

func (r *Value) AsInt() int

func (*Value) AsInt64

func (r *Value) AsInt64() int64

func (*Value) AsObject

func (r *Value) AsObject() *Object

类型转换

func (*Value) AsString

func (r *Value) AsString() string

func (*Value) GetType

func (r *Value) GetType() int

获取值类型

func (*Value) IsArray

func (r *Value) IsArray() bool

func (*Value) IsObject

func (r *Value) IsObject() bool

类型判断

func (*Value) ToBytes

func (r *Value) ToBytes() []byte

序列化成 []byte

func (*Value) ToString

func (r *Value) ToString() string

Jump to

Keyboard shortcuts

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