หมายเหตุ
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลอง ลงชื่อเข้าใช้หรือเปลี่ยนไดเรกทอรีได้
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลองเปลี่ยนไดเรกทอรีได้
The STRINGTOBOOLEAN function converts a string expression to a boolean.
An Azure Cosmos DB system function that returns a string expression converted to a boolean.
Syntax
STRINGTOBOOLEAN(<string_expr>)
Arguments
| Description | |
|---|---|
string_expr |
A string expression. |
Return types
Returns a boolean value.
Examples
This section contains examples of how to use this query language construct.
Convert string to boolean
In this example, the STRINGTOBOOLEAN function is used to parse various string values into booleans.
SELECT VALUE {
parseBooleanString: STRINGTOBOOLEAN("true"),
parseWithPrefix: STRINGTOBOOLEAN("true "),
parseWithSuffix: STRINGTOBOOLEAN(" false"),
parseWithWhitespace: STRINGTOBOOLEAN(" false "),
parseBoolean: STRINGTOBOOLEAN(true),
parseUndefined: STRINGTOBOOLEAN(undefined),
parseNull: STRINGTOBOOLEAN(null)
}
[
{
"parseBooleanString": true,
"parseWithPrefix": true,
"parseWithSuffix": false,
"parseWithWhitespace": false
}
]
Remarks
- This function doesn't utilize the index.