apoc.convert.toString

Function APOC Core Deprecated

apoc.convert.toString(value) | tries it’s best to convert the value to a string

Signature

apoc.convert.toString(string :: ANY?) :: (STRING?)

Input parameters

Name Type Default

string

ANY?

null

Usage Examples

Convert numeric value to string
RETURN apoc.convert.toString(1) AS output;
Table 1. Results
Output

"1"

Convert boolean value to string
RETURN apoc.convert.toString(true) AS output;
Table 2. Results
Output

"true"

Convert map to string
RETURN apoc.convert.toString({key: "value"}) AS output;
Table 3. Results
Output

"{key=value}"

This function has been deprecated and will be removed in version 5.0. The functionality is replaced by the Neo4j functions toString(value) and the more permissive toStringOrNull(value). The Neo4j functions do not have exactly the same behavior as the APOC ones - the following table is intended to assist migration by highlighting the differences:

Table 4. Migration Path to toString() / toStringOrNull()
Input apoc.convert.toString() toString() toStringOrNull()

null

null

null

null

0

"0"

"0"

"0"

1.5

"1"

"1"

"1"

"string"

"string"

"string"

"string"

[1,2,3] [1]

"[1,2,3]"

Error

null

{a:'map'} [1]

"{a=map}"

Error

null

true

"true"

"true"

"true"

false

"false"

"false"

"false"

datetime("2000-01-01T00:00:00.000+0000")

"2000-01-01T00:00Z"

"2000-01-01T00:00Z"

"2000-01-01T00:00Z"

Point({x:0.0, y:0.0})

"point({x: 0.0, y: 0.0, crs: 'cartesian'})"

"point({x: 0.0, y: 0.0, crs: 'cartesian'})"

"point({x: 0.0, y: 0.0, crs: 'cartesian'})"

Node [1]

"Node[0]"

Error

null

Relationship [1]

"(94)-[TYPE,112]→(0)"

Error

null

Path ()-[]-() [1]

"(0)-[TYPE,1194]→(335)"

Error

null


1. There is no Neo4j equivalent toString for these types