forked from mirror/gjson
Merge pull request #66 from Hexilee/master
Result.Bool() can parse 'false' as false
This commit is contained in:
commit
01f00f1296
2
gjson.go
2
gjson.go
|
@ -96,7 +96,7 @@ func (t Result) Bool() bool {
|
||||||
case True:
|
case True:
|
||||||
return true
|
return true
|
||||||
case String:
|
case String:
|
||||||
return t.Str != "" && t.Str != "0"
|
return t.Str != "" && t.Str != "0" && t.Str != "false"
|
||||||
case Number:
|
case Number:
|
||||||
return t.Num != 0
|
return t.Num != 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ func TestTimeResult(t *testing.T) {
|
||||||
func TestParseAny(t *testing.T) {
|
func TestParseAny(t *testing.T) {
|
||||||
assert(t, Parse("100").Float() == 100)
|
assert(t, Parse("100").Float() == 100)
|
||||||
assert(t, Parse("true").Bool())
|
assert(t, Parse("true").Bool())
|
||||||
assert(t, Parse("valse").Bool() == false)
|
assert(t, Parse("false").Bool() == false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestManyVariousPathCounts(t *testing.T) {
|
func TestManyVariousPathCounts(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue