Result.Bool() can parse 'false' as false
This commit is contained in:
parent
aff9dcea3c
commit
9fa9086994
2
gjson.go
2
gjson.go
|
@ -96,7 +96,7 @@ func (t Result) Bool() bool {
|
|||
case True:
|
||||
return true
|
||||
case String:
|
||||
return t.Str != "" && t.Str != "0"
|
||||
return t.Str != "" && t.Str != "0" && t.Str != "false"
|
||||
case Number:
|
||||
return t.Num != 0
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ func TestTimeResult(t *testing.T) {
|
|||
func TestParseAny(t *testing.T) {
|
||||
assert(t, Parse("100").Float() == 100)
|
||||
assert(t, Parse("true").Bool())
|
||||
assert(t, Parse("valse").Bool() == false)
|
||||
assert(t, Parse("false").Bool() == false)
|
||||
}
|
||||
|
||||
func TestManyVariousPathCounts(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user