Επεξεργασία

Κοινή χρήση μέσω


StringToBoolean (NoSQL query)

APPLIES TO: NoSQL

Converts a string expression to a boolean.

Syntax

StringToBoolean(<string_expr>)  

Arguments

Description
string_expr A string expression.

Return types

Returns a boolean value.

Examples

The following example illustrates how this function works with various data types.

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 use the index.
  • If the expression can't be converted, the function returns undefined.

Note

For more information on the JSON format, see https://json.org.