add bool support
This commit is contained in:
@ -74,6 +74,14 @@ func (g *gjsonRead) Float(dataPath string) (float64, error) {
|
||||
return gjson_hack.Float64(g.gjsonResult.Get(dataPath))
|
||||
}
|
||||
|
||||
func (g *gjsonRead) Bool(dataPath string) (bool, error) {
|
||||
res := g.gjsonResult.Get(dataPath)
|
||||
if !res.IsBool() {
|
||||
return false, errors.New(dataPath + ": is not a bool")
|
||||
}
|
||||
return res.Bool(), nil
|
||||
}
|
||||
|
||||
func (g *gjsonRead) String(dataPath string) (string, error) {
|
||||
if !g.Exist(dataPath) {
|
||||
return "", errors.New(dataPath + ": not found")
|
||||
|
Reference in New Issue
Block a user