Documentation ¶
Overview ¶
Package config provides JSON configuration
Index ¶
- type JSON
- func (j *JSON) CloneConfig() *JSON
- func (j *JSON) GetBoolOrDefaullt(path string, defaultValue bool) bool
- func (j *JSON) GetConfig(path string) (*JSON, error)
- func (j *JSON) GetConfigArray(path string) ([]*JSON, error)
- func (j *JSON) GetConfigMap(path string) (map[string]*JSON, error)
- func (j *JSON) GetFloat64OrDefaullt(path string, defaultValue float64) float64
- func (j *JSON) GetInt64OrDefaullt(path string, defaultValue int64) int64
- func (j *JSON) GetStringOrDefaullt(path string, defaultValue string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSON ¶
JSON JSON format configuration file
func NewJSONFromBytes ¶
NewJSONFromBytes gets json configuration from byte stream b and returns an error if the json format is wrong
func NewJSONFromEncodingJSON ¶
NewJSONFromEncodingJSON gets JSON from encoded JSON j
func NewJSONFromFile ¶
NewJSONFromFile gets json configuration from the file named filename And return an error if there is a json format error or a file read error
func NewJSONFromString ¶
NewJSONFromString gets json configuration from string s and returns an error if the json format is wrong
func (*JSON) CloneConfig ¶
CloneConfig clones the json configuration file
func (*JSON) GetBoolOrDefaullt ¶
GetBoolOrDefaullt gets the BOOL value corresponding to the path. For the following json
{ "a":{ "b":[{ c:"x" }] } }
To access the x string, the access path for each layer of path is a, a.b, a.b.0, a.b.0.c If the corresponding path is not int64 or does not exist, defaultValue will be returned
func (*JSON) GetConfig ¶
GetConfig gets the value configuration file corresponding to the path. For the following json
{ "a":{ "b":[{ c:"x" }] } }
To access the x string, the access path for each layer of path is a, a.b, a.b.0, a.b.0.c If the corresponding path is not a json structure or does not exist, an error will be returned
func (*JSON) GetConfigArray ¶
GetConfigArray gets the configuration array corresponding to the path. For the following json
{ "a":{ "b":[{ c:"x" }] } }
To access the x string, the access path for each layer of path is a, a.b, a.b.0, a.b.0.c If the corresponding path is not a configuration array or does not exist, an error will be returned
func (*JSON) GetConfigMap ¶
GetConfigMap gets the configuration mapping corresponding to the path. For the following json
{ "a":{ "b":[{ c:"x" }] } }
To access the x string, the access path for each layer of path is a, a.b, a.b.0, a.b.0.c If the corresponding path is not a configuration mapping or does not exist, an error will be returned
func (*JSON) GetFloat64OrDefaullt ¶
GetFloat64OrDefaullt gets the float64 value corresponding to the path. For the following json
{ "a":{ "b":[{ c:"x" }] } }
To access the x string, the access path for each layer of path is a, a.b, a.b.0, a.b.0.c If the corresponding path is not float64 or does not exist, defaultValue will be returned
func (*JSON) GetInt64OrDefaullt ¶
GetInt64OrDefaullt gets the int64 value corresponding to the path. For the following json
{ "a":{ "b":[{ c:"x" }] } }
To access the x string, the access path for each layer of path is a, a.b, a.b.0, a.b.0.c If the corresponding path is not int64 or does not exist, defaultValue will be returned
func (*JSON) GetStringOrDefaullt ¶
GetStringOrDefaullt gets the string value corresponding to the path. For the following json
{ "a":{ "b":[{ c:"x" }] } }
To access the x string, the access path for each layer of path is a, a.b, a.b.0, a.b.0.c If the corresponding path is not a string or does not exist, defaultValue will be returned