Rediger

Del via


StringToNumber (NoSQL query)

APPLIES TO: NoSQL

Converts a string expression to a number.

Syntax

StringToNumber(<string_expr>)  

Arguments

Description
string_expr A string expression.

Return types

Returns a number value.

Examples

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

SELECT VALUE {
    parseIntegerString: StringToNumber("100"), 
    parseDecimalString: StringToNumber("3.14"),
    parseWithWhitespace: StringToNumber("   60   "), 
    parseScientific: StringToNumber("-1.79769e+308"),
    parseInvalid: StringToNumber("Hello"),
    parseUndefined: StringToNumber(undefined),
    parseNull: StringToNumber(null),
    parseNaN: StringToNumber(NaN),
    parseInfinity: StringToNumber(Infinity)
}
[
  {
    "parseIntegerString": 100,
    "parseDecimalString": 3.14,
    "parseWithWhitespace": 60,
    "parseScientific": -1.79769e+308
  }
]

Remarks

  • This function doesn't use the index.
  • String expressions are parsed as a JSON number expression.
  • Numbers in JSON must be an integer or a floating point.
  • If the expression can't be converted, the function returns undefined.

Note

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