From 82f549e6ee78eb18d7536692d608a531c35f0458 Mon Sep 17 00:00:00 2001 From: tidwall Date: Wed, 2 Feb 2022 04:49:11 -0700 Subject: [PATCH] Added IsBool See #264 --- gjson.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gjson.go b/gjson.go index cb61573..f863689 100644 --- a/gjson.go +++ b/gjson.go @@ -214,6 +214,11 @@ func (t Result) IsArray() bool { return t.Type == JSON && len(t.Raw) > 0 && t.Raw[0] == '[' } +// IsBool returns true if the result value is a JSON boolean. +func (t Result) IsBool() bool { + return t.Type == True || t.Type == False +} + // ForEach iterates through values. // If the result represents a non-existent value, then no values will be // iterated. If the result is an Object, the iterator will pass the key and