convert

Module used for conversion of one data type to another.

TraitValue
Module typeutil
ImplementationPython
Parallelismsequential

Function

str2object()

Inline function that converts the input string to an object the string represents, using Python's json.dumps function.

Input:

  • string: string ➡ The input string that will be converted.

Output:

  • mgp.Any ➡ Since the function is inline, the output is not named, and can be of various data types, depending of the content of the string.

Usage:

In this case, the string will be converted to a list:

RETURN convert.str2object("[1,2,3]") AS result;
+----------------------------+
| result                     |
+----------------------------+
| [1, 2, 3]                  |
+----------------------------+

In this use case, the string will be converted into a map, containing a list:

RETURN convert.str2object('{"key": [1,2,3]}') AS result;
+----------------------------+
| result                     |
+----------------------------+
| {"key": [1,2,3]}           |
+----------------------------+