IS_BOOL (Azure Cosmos DB)IS_BOOL (Azure Cosmos DB)

返回一个布尔值,指示指定表达式的类型是否为布尔表达式。Returns a Boolean value indicating if the type of the specified expression is a Boolean.

语法Syntax

IS_BOOL(<expr>)  

参数Arguments

exprexpr
是任何表达式。Is any expression.

返回类型Return types

返回一个布尔表达式。Returns a Boolean expression.

示例Examples

以下示例使用 IS_BOOL 函数检查 JSON 布尔、数字、字符串、null、对象、数组和 undefined 类型的对象。The following example checks objects of JSON Boolean, number, string, null, object, array, and undefined types using the IS_BOOL function.

SELECT   
    IS_BOOL(true) AS isBool1,   
    IS_BOOL(1) AS isBool2,  
    IS_BOOL("value") AS isBool3,   
    IS_BOOL(null) AS isBool4,  
    IS_BOOL({prop: "value"}) AS isBool5,   
    IS_BOOL([1, 2, 3]) AS isBool6,  
    IS_BOOL({prop: "value"}.prop2) AS isBool7  

下面是结果集。Here is the result set.

[{"isBool1":true,"isBool2":false,"isBool3":false,"isBool4":false,"isBool5":false,"isBool6":false,"isBool7":false}]

备注Remarks

此系统函数将从范围索引中获益。This system function will benefit from a range index.

后续步骤Next steps