IS_PRIMITIVE (Azure Cosmos DB)IS_PRIMITIVE (Azure Cosmos DB)

返回一个布尔值,指示指定表达式的类型是否为一个(字符串、布尔、数值或 null)。Returns a Boolean value indicating if the type of the specified expression is a primitive (string, Boolean, numeric, or null).

语法Syntax

IS_PRIMITIVE(<expr>)  

参数Arguments

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

返回类型Return types

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

示例Examples

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

SELECT   
    IS_PRIMITIVE(true) AS isPrim1,   
    IS_PRIMITIVE(1) AS isPrim2,  
    IS_PRIMITIVE("value") AS isPrim3,   
    IS_PRIMITIVE(null) AS isPrim4,  
    IS_PRIMITIVE({prop: "value"}) AS isPrim5,   
    IS_PRIMITIVE([1, 2, 3]) AS isPrim6,  
    IS_PRIMITIVE({prop: "value"}.prop2) AS isPrim7  

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

[{"isPrim1": true, "isPrim2": true, "isPrim3": true, "isPrim4": true, "isPrim5": false, "isPrim6": false, "isPrim7": false}]  

备注Remarks

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

后续步骤Next steps