Documentation
¶
Index ¶
- func Author() string
- func Dump(path string, data interface{}) error
- func Dumps(data interface{}) (string, error)
- func License() string
- func PrettyDumps(data interface{}) (string, error)
- func Version() string
- type Json
- func (j *Json) Array() (result []interface{}, err error)
- func (j *Json) Bool() (result bool, err error)
- func (j *Json) Del(key string)
- func (j *Json) Dump(path string) (err error)
- func (j *Json) Dumps() (result string, err error)
- func (j *Json) Float64() (result float64, err error)
- func (j *Json) Get(key string) *Json
- func (j *Json) Has(key string) bool
- func (j *Json) Index(i int) *Json
- func (j *Json) Int() (result int, err error)
- func (j *Json) Int64() (result int64, err error)
- func (j *Json) IsArray() bool
- func (j *Json) IsMap() bool
- func (j *Json) Len() int
- func (j *Json) Load(path string) error
- func (j *Json) Loads(text string) error
- func (j *Json) Map() (result map[string]interface{}, err error)
- func (j *Json) MustArray(args ...[]interface{}) []interface{}
- func (j *Json) MustBool(args ...bool) bool
- func (j *Json) MustFloat64(args ...float64) float64
- func (j *Json) MustInt(args ...int) int
- func (j *Json) MustInt64(args ...int64) int64
- func (j *Json) MustMap(args ...map[string]interface{}) map[string]interface{}
- func (j *Json) MustString(args ...string) string
- func (j *Json) MustStringArray(args ...[]string) []string
- func (j *Json) MustTime(args ...interface{}) time.Time
- func (j *Json) MustUint64(args ...uint64) uint64
- func (j *Json) PrettyDumps() (result string, err error)
- func (j *Json) Set(key string, value interface{})
- func (j *Json) SetHtmlEscape(escape bool)
- func (j *Json) String() (result string, err error)
- func (j *Json) StringArray() (result []string, err error)
- func (j *Json) Time(args ...string) (result time.Time, err error)
- func (j *Json) Uint64() (result uint64, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrettyDumps ¶ added in v0.21.0
PrettyDumps marshal json object to string, with identation
Types ¶
type Json ¶ added in v0.21.0
type Json struct {
// contains filtered or unexported fields
}
Json storing json data
func New ¶ added in v0.21.0
func New(args ...interface{}) *Json
New returns a pointer to a new Json object
data_json := New() data_json := New(type Data struct{data string}{"zzz"}) data_json := New(map[string]interface{}{"iam": "Li Kexian"})
func (*Json) Del ¶ added in v0.21.0
Del delete key-value from json object, dot(.) separated key is supported
json.Del("status") json.Del("status.code") ! NOT SUPPORTED json.Del("result.intlist.3")
func (*Json) Get ¶ added in v0.21.0
Get returns the pointer to json object by key, dot(.) separated key is supported
json.Get("status").Int() json.Get("status.code").Int() json.Get("result.intlist.3").Int()
func (*Json) Has ¶ added in v0.21.0
Has check json object has key, dot(.) separated key is supported
json.Has("status") json.Has("status.code") json.Has("result.intlist.3")
func (*Json) Index ¶ added in v0.21.0
Index returns a pointer to the index of json object
json.Get("int_list").Index(1).Int()
func (*Json) MustArray ¶ added in v0.21.0
func (j *Json) MustArray(args ...[]interface{}) []interface{}
MustArray returns as array from json object with optional default value if error return default(if set) or panic
func (*Json) MustBool ¶ added in v0.21.0
MustBool returns as bool from json object with optional default value if error return default(if set) or panic
func (*Json) MustFloat64 ¶ added in v0.21.0
MustFloat64 returns as float64 from json object with optional default value if error return default(if set) or panic
func (*Json) MustInt ¶ added in v0.21.0
MustInt returns as int from json object with optional default value if error return default(if set) or panic
func (*Json) MustInt64 ¶ added in v0.21.0
MustInt64 returns as int64 from json object with optional default value if error return default(if set) or panic
func (*Json) MustMap ¶ added in v0.21.0
MustMap returns as map from json object with optional default value if error return default(if set) or panic
func (*Json) MustString ¶ added in v0.21.0
MustString returns as string from json object with optional default value if error return default(if set) or panic
func (*Json) MustStringArray ¶ added in v0.21.0
MustStringArray returns as string from json object with optional default value if error return default(if set) or panic
func (*Json) MustTime ¶ added in v0.21.0
MustTime returns as time.Time from json object if error return default(if set) or panic
json.Time() // No format, No default json.Time("2006-01-02 15:04:05") // Has format, No default json.Time(time.Unix(1548907870, 0)) // No format, Has default json.Time("2006-01-02 15:04:05", time.Unix(1548907870, 0)) // Has format, Has default
func (*Json) MustUint64 ¶ added in v0.21.0
MustUint64 returns as uint64 from json object with optional default value if error return default(if set) or panic
func (*Json) PrettyDumps ¶ added in v0.21.0
PrettyDumps marshal json object to string, with identation
func (*Json) Set ¶ added in v0.21.0
Set set key-value to json object, dot(.) separated key is supported
json.Set("status", 1) json.Set("status.code", 1) ! NOT SUPPORTED json.Set("result.intlist.3", 666)
func (*Json) SetHtmlEscape ¶ added in v0.21.0
SetHtmlEscape set html escape for escaping of <, >, and & in JSON strings
func (*Json) StringArray ¶ added in v0.21.0
StringArray returns as string array from json object