apoc.convert.toJson

Function APOC Core

apoc.convert.toJson([1,2,3]) or toJson({a:42,b:"foo",c:[1,2,3]})

Signature

apoc.convert.toJson(value :: ANY?) :: (STRING?)

Input parameters

Name Type Default

value

ANY?

null

Usage Examples

Convert map to JSON
RETURN apoc.convert.toJson({
  name: "Michael",
  time: datetime()
}) AS output;
Table 1. Results
Output

"{\"name\":\"Michael\",\"time\":\"2020-11-03T12:05:50.963Z\"}"

Convert node properties to JSON
CREATE (node:Node {id: 4, name: "Foo"})
RETURN apoc.convert.toJson(properties(node)) AS output;
Table 2. Results
Output

"{\"name\":\"Foo\",\"id\":4}"