Added IsBool

See #264
This commit is contained in:
tidwall 2022-02-02 04:49:11 -07:00
parent e4fc67c92a
commit 82f549e6ee
1 changed files with 5 additions and 0 deletions

View File

@ -214,6 +214,11 @@ func (t Result) IsArray() bool {
return t.Type == JSON && len(t.Raw) > 0 && t.Raw[0] == '[' 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. // ForEach iterates through values.
// If the result represents a non-existent value, then no values will be // 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 // iterated. If the result is an Object, the iterator will pass the key and