jsonconv

package
v0.0.0-...-255a7ba Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: LGPL-2.1 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DataTypeError         = errors.New("invalid parameter type")
	ParaError             = errors.New("parameter invalid")
	JsonFormatError       = errors.New("json string format error")
	JsonTypeError         = errors.New("json target type error")
	IndexOutOfBoundsError = errors.New("index out of bounds")

	NotAnArrayError  = errors.New("target is not an array")
	NotAnObjectError = errors.New("target is not an object")
	NotAStringError  = errors.New("target is not a string")
	NotANumberError  = errors.New("target is not a number")
	NotABoolError    = errors.New("target is not a bool")

	ObjectNotFoundError = errors.New("object not found")
)

Functions

func Marshal

func Marshal(obj *JsonValue, opts ...Option) (string, error)

==================== Marshal

func SqlToJson

func SqlToJson(u interface{}, options ...Option) (string, error)

*

  • Valid parameter type: struct ptr

Types

type Filter

type Filter int
const (
	Normal Filter = iota
	IncludeMode
	ExcludeMode
)

type JsonValue

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

func NewArray

func NewArray() *JsonValue

func NewBool

func NewBool(b bool) *JsonValue

func NewBoolean

func NewBoolean(b bool) *JsonValue

func NewByUnmarshal

func NewByUnmarshal(s string) (*JsonValue, error)

func NewFloat

func NewFloat(f float64) *JsonValue

func NewFromString

func NewFromString(s string) (*JsonValue, error)

func NewInt

func NewInt(i int) *JsonValue

func NewInt32

func NewInt32(i int32) *JsonValue

func NewInt64

func NewInt64(i int64) *JsonValue

func NewNull

func NewNull() *JsonValue

func NewObject

func NewObject() *JsonValue

func NewString

func NewString(s string) *JsonValue

==== NewXxx ====

func NewUint

func NewUint(i uint) *JsonValue

func NewUint32

func NewUint32(i uint32) *JsonValue

func NewUint64

func NewUint64(i uint64) *JsonValue

func (*JsonValue) Append

func (this *JsonValue) Append(newOne *JsonValue, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) AppendBool

func (this *JsonValue) AppendBool(b bool, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) AppendBoolean

func (this *JsonValue) AppendBoolean(b bool, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) AppendFloat

func (this *JsonValue) AppendFloat(f float64, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) AppendInt

func (this *JsonValue) AppendInt(i int, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) AppendInt32

func (this *JsonValue) AppendInt32(i int32, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) AppendInt64

func (this *JsonValue) AppendInt64(i int64, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) AppendNull

func (this *JsonValue) AppendNull(keys ...interface{}) (*JsonValue, error)

func (*JsonValue) AppendString

func (this *JsonValue) AppendString(s string, keys ...interface{}) (*JsonValue, error)

==== AppendXxx ====

func (*JsonValue) AppendUint

func (this *JsonValue) AppendUint(i uint, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) AppendUint32

func (this *JsonValue) AppendUint32(i uint32, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) AppendUint64

func (this *JsonValue) AppendUint64(i uint64, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) ArrayForeach

func (this *JsonValue) ArrayForeach(callback func(index int, value *JsonValue) error) error

==================== foreach

func (*JsonValue) Bool

func (obj *JsonValue) Bool() bool

func (*JsonValue) Boolean

func (obj *JsonValue) Boolean() bool

func (*JsonValue) Delete

func (obj *JsonValue) Delete(first interface{}, keys ...interface{}) error

==================== object modification

func (*JsonValue) Float

func (obj *JsonValue) Float() float64

func (*JsonValue) Get

func (obj *JsonValue) Get(first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) GetAtIndex

func (obj *JsonValue) GetAtIndex(index int) (*JsonValue, error)

func (*JsonValue) GetBool

func (obj *JsonValue) GetBool(first interface{}, keys ...interface{}) (bool, error)

func (*JsonValue) GetBoolean

func (obj *JsonValue) GetBoolean(first interface{}, keys ...interface{}) (bool, error)

func (*JsonValue) GetByKey

func (obj *JsonValue) GetByKey(keys ...string) (*JsonValue, error)

children access

func (*JsonValue) GetFloat

func (obj *JsonValue) GetFloat(first interface{}, keys ...interface{}) (float64, error)

func (*JsonValue) GetInt

func (obj *JsonValue) GetInt(first interface{}, keys ...interface{}) (int, error)

func (*JsonValue) GetInt32

func (obj *JsonValue) GetInt32(first interface{}, keys ...interface{}) (int32, error)

func (*JsonValue) GetInt64

func (obj *JsonValue) GetInt64(first interface{}, keys ...interface{}) (int64, error)

==== GetXxx ====

func (*JsonValue) GetString

func (obj *JsonValue) GetString(first interface{}, keys ...interface{}) (string, error)

func (*JsonValue) GetUint

func (obj *JsonValue) GetUint(first interface{}, keys ...interface{}) (uint, error)

func (*JsonValue) GetUint32

func (obj *JsonValue) GetUint32(first interface{}, keys ...interface{}) (uint32, error)

func (*JsonValue) GetUint64

func (obj *JsonValue) GetUint64(first interface{}, keys ...interface{}) (uint64, error)

func (*JsonValue) Insert

func (this *JsonValue) Insert(newOne *JsonValue, index interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) InsertBool

func (this *JsonValue) InsertBool(b bool, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) InsertBoolean

func (this *JsonValue) InsertBoolean(b bool, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) InsertFloat

func (this *JsonValue) InsertFloat(f float64, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) InsertInt

func (this *JsonValue) InsertInt(i int, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) InsertInt32

func (this *JsonValue) InsertInt32(i int32, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) InsertInt64

func (this *JsonValue) InsertInt64(i int64, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) InsertNull

func (this *JsonValue) InsertNull(first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) InsertString

func (this *JsonValue) InsertString(s string, first interface{}, keys ...interface{}) (*JsonValue, error)

==== InsertXxx ====

func (*JsonValue) InsertUint

func (this *JsonValue) InsertUint(i uint, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) InsertUint32

func (this *JsonValue) InsertUint32(i uint32, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) InsertUint64

func (this *JsonValue) InsertUint64(i uint64, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) Int

func (obj *JsonValue) Int() int

func (*JsonValue) Int32

func (obj *JsonValue) Int32() int32

func (*JsonValue) Int64

func (obj *JsonValue) Int64() int64

func (*JsonValue) IsArray

func (obj *JsonValue) IsArray() bool

func (*JsonValue) IsBool

func (obj *JsonValue) IsBool() bool

func (*JsonValue) IsBoollean

func (obj *JsonValue) IsBoollean() bool

func (*JsonValue) IsFloat

func (this *JsonValue) IsFloat() bool

IsXxx for number type

func (*JsonValue) IsNull

func (obj *JsonValue) IsNull() bool

func (*JsonValue) IsNumber

func (obj *JsonValue) IsNumber() bool

func (*JsonValue) IsObject

func (obj *JsonValue) IsObject() bool

func (*JsonValue) IsSigned

func (this *JsonValue) IsSigned() bool

func (*JsonValue) IsString

func (obj *JsonValue) IsString() bool

func (*JsonValue) IsUnsigned

func (this *JsonValue) IsUnsigned() bool

func (*JsonValue) Len

func (obj *JsonValue) Len() int

func (*JsonValue) Length

func (obj *JsonValue) Length() int

func (*JsonValue) Marshal

func (obj *JsonValue) Marshal(opts ...Option) (string, error)

func (*JsonValue) MergeFrom

func (to *JsonValue) MergeFrom(from *JsonValue, optList ...Option) error

func (*JsonValue) ObjectForeach

func (this *JsonValue) ObjectForeach(callback func(key string, value *JsonValue) error) error

func (*JsonValue) Set

func (this *JsonValue) Set(newOne *JsonValue, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) SetArray

func (this *JsonValue) SetArray(first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) SetBool

func (this *JsonValue) SetBool(b bool, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) SetBoolean

func (this *JsonValue) SetBoolean(b bool, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) SetFloat

func (this *JsonValue) SetFloat(f float64, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) SetInt

func (this *JsonValue) SetInt(i int, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) SetInt32

func (this *JsonValue) SetInt32(i int32, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) SetInt64

func (this *JsonValue) SetInt64(i int64, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) SetNull

func (this *JsonValue) SetNull(first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) SetObject

func (this *JsonValue) SetObject(first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) SetString

func (this *JsonValue) SetString(s string, first interface{}, keys ...interface{}) (*JsonValue, error)

==== SetXxx ====

func (*JsonValue) SetUint

func (this *JsonValue) SetUint(i uint, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) SetUint32

func (this *JsonValue) SetUint32(i uint32, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) SetUint64

func (this *JsonValue) SetUint64(i uint64, first interface{}, keys ...interface{}) (*JsonValue, error)

func (*JsonValue) String

func (obj *JsonValue) String() string

simple values

func (*JsonValue) Swap

func (this *JsonValue) Swap(i, j int) error

func (*JsonValue) Type

func (obj *JsonValue) Type() ValueType

types

func (*JsonValue) TypeString

func (obj *JsonValue) TypeString() string

func (*JsonValue) Uint

func (obj *JsonValue) Uint() uint

func (*JsonValue) Uint32

func (obj *JsonValue) Uint32() uint32

func (*JsonValue) Uint64

func (obj *JsonValue) Uint64() uint64

type Option

type Option struct {
	// for JsonValue
	ShowNull    bool
	EnsureAscii bool
	FloatDigits uint8
	SortMode    Sort
	// for sql2json
	TimeDigits uint8
	FilterMode Filter
	FilterList []string
	// for JsonValue.MergeFrom()
	OverrideArray  bool
	OverrideObject bool
}

type Sort

type Sort int
const (
	Random Sort = iota
	DictAsc
	DictDesc
)

Jump to

Keyboard shortcuts

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