From 9fa9086994a7773e2222bbb05da164bf2c2ffed6 Mon Sep 17 00:00:00 2001 From: Hexilee Date: Fri, 23 Feb 2018 20:25:48 +0800 Subject: [PATCH] Result.Bool() can parse 'false' as false --- gjson.go | 2 +- gjson_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gjson.go b/gjson.go index ce32a7d..d2e11b9 100644 --- a/gjson.go +++ b/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 } diff --git a/gjson_test.go b/gjson_test.go index c01dc2f..9258e1b 100644 --- a/gjson_test.go +++ b/gjson_test.go @@ -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) {