Type Conversion Functions
The functions on this page are used to convert data from one type to another in the GSQL query language.
parse_json_array()
Description
Converts a string into a JSON array. The string must be properly formatted, or the function will generate a run-time error. To be properly formatted, besides having the proper nesting and matching of curly braces { }
and brackets [ ]
, each value field must be one of the following:
-
a string
-
a number
-
a boolean
-
a JSONOBJECT - Each key of a key-value pair must be a string in double quotes.
-
a JSON array
parse_json_object()
Description
Converts a string into a JSON object. The string must be properly formatted, or the function will generate a run-time error. To be properly formatted, besides having the proper nesting and matching of curly braces { }
and brackets [ ]
, each value field must be one of the following:
-
a string
-
a number
-
a boolean
-
a JSONOBJECT - Each key of a key-value pair must be a string in double quotes, and the quotes need to be escaped with a backlash-escape
\
. However, if you are supplying the string in GraphStudio as a parameter, you do not need the backlash-escape since string values are not enclosed in double quotes. -
a JSON array
to_string()
Description
Converts a number to a string using the C++ printf function with the g
specifier, which means it always produces the shortest output.
Example
to_string(1000.1) -> "1000.1" to_string(0.0000000001) -> "1E-10" to_string(12300000000) -> "12300000000" // Using an `INT` or `UINT` value returns the full number as a string without scientific notation to_string(12300000000.0) -> "1.23e+10" // Using a `DOUBLE` value returns scientific notation for large numbers to_string(12300000000.0) -> "1.23e+10" // Using a `FLOAT` value also returns scientific notation for large numbers