JsonMapper

package
v0.7.2-test Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BoolType = reflect.TypeOf(false)
View Source
var Float64Type = reflect.TypeOf(float64(1))
View Source
var IntType = reflect.TypeOf(1)

** reflect type definition **

View Source
var JsonMapType = reflect.TypeOf((map[string]interface{})(nil))
View Source
var SPLIT_TOKEN string = "."

** Token for key depth **

View Source
var SliceMapType = reflect.TypeOf([]map[string]interface{}(nil))
View Source
var SliceType = reflect.TypeOf([]interface{}(nil))
View Source
var StringType = reflect.TypeOf(string(""))
View Source
var YamlMapType = reflect.TypeOf((map[interface{}]interface{})(nil))

yamltype

Functions

func Convert

func Convert(o interface{}) string

Convert: obejct to json string

func FromJson

func FromJson(_byte []byte, _o interface{}) error

FromJson : json bytes to object(struct)

func ToJson

func ToJson(_o interface{}) ([]byte, error)

ToJson : object(struct) to json bytes

Types

type JsonMap

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

func NewBytes

func NewBytes(b []byte) (*JsonMap, error)

NewBytes : new jmap from json bytes

func NewFile

func NewFile(path string) (*JsonMap, error)

NewFile: new jamp from file

func NewObject

func NewObject(o interface{}) (*JsonMap, error)

NewObject: new jmap from map[string]interface{}

func NewString

func NewString(s string) (*JsonMap, error)

NewString: new jmap from string

func (*JsonMap) CopyObject

func (j *JsonMap) CopyObject() map[string]interface{}

func (*JsonMap) Find

func (j *JsonMap) Find(k string) interface{}

Find : find value from json key

func (*JsonMap) FindBool

func (j *JsonMap) FindBool(k string, defaultValue bool) bool

func (*JsonMap) FindFloat32

func (j *JsonMap) FindFloat32(k string, defaultValue float32) float32

func (*JsonMap) FindFloat64

func (j *JsonMap) FindFloat64(k string, defaultValue float64) float64

func (*JsonMap) FindInt

func (j *JsonMap) FindInt(k string, defaultValue int) int

func (*JsonMap) FindInt32

func (j *JsonMap) FindInt32(k string, defaultValue int32) int32

func (*JsonMap) FindInt64

func (j *JsonMap) FindInt64(k string, defaultValue int64) int64

func (*JsonMap) FindMap

func (j *JsonMap) FindMap(k string, defaultValue map[string]interface{}) map[string]interface{}

func (*JsonMap) FindSilce

func (j *JsonMap) FindSilce(k string, defaultValue []interface{}) []interface{}

func (*JsonMap) FindString

func (j *JsonMap) FindString(k string, defaultValue string) string

func (*JsonMap) GetObject

func (j *JsonMap) GetObject() map[string]interface{}

func (*JsonMap) Insert

func (j *JsonMap) Insert(base, k string, v interface{})

Insert : insert/update, when insert root, set [base == ""]

func (*JsonMap) PPrint

func (j *JsonMap) PPrint() string

PPrint : pretty print

func (*JsonMap) Print

func (j *JsonMap) Print() string

Print : print

func (*JsonMap) Remove

func (j *JsonMap) Remove(k string)

Remove : remove value from key. prevent remove root.

func (*JsonMap) Search

func (j *JsonMap) Search(keyIncluded string, searchOpt string) []map[string]interface{}

TODO: .... Search : Retrieve all values ​​matching a condition

type YamlMap

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

func NewYamlMap

func NewYamlMap(strYaml string) (*YamlMap, error)

func NewYamlMapFile

func NewYamlMapFile(yamlFile string) (*YamlMap, error)

func NewYamlObject

func NewYamlObject(o interface{}) (*YamlMap, error)

func (*YamlMap) Find

func (o *YamlMap) Find(idx int, k string) interface{}

func (*YamlMap) Insert

func (o *YamlMap) Insert(idx int, base, k string, v interface{})

Insert : insert/update, when insert root, set [base == ""]

func (*YamlMap) Print

func (o *YamlMap) Print(idx int) string

func (*YamlMap) Prints

func (o *YamlMap) Prints() string

func (*YamlMap) Remove

func (o *YamlMap) Remove(idx int, k string)

Remove

type YamlObject

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

func (*YamlObject) Print

func (o *YamlObject) Print() (string, error)

Jump to

Keyboard shortcuts

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