apoc.convert.setJsonProperty

Details

Syntax

apoc.convert.setJsonProperty(node, key, value)

Description

Serializes the given JSON object and sets it as a property on the given NODE.

Input arguments

Name

Type

Description

node

NODE

The node to set the JSON property on.

key

STRING

The name of the property to set.

value

ANY

The property to serialize as a JSON object.

Usage examples

The examples in this section are based on the following sample graph:

CREATE (:Person {json:'{a:[1,2,3]}'});
MATCH (p:Person)
CALL apoc.convert.setJsonProperty(p, 'json', {a: [4,5,6]})
RETURN p
Results
p

(:Person {json: "{\"a\":[4,5,6]}"})

We can extract the JSON value from the node using apoc.convert.getJsonPropertyMap:

MATCH (p:Person)
RETURN apoc.convert.getJsonPropertyMap(p, "json") AS map;
Results
map

{a: [4, 5, 6]}