apoc.convert.setJsonProperty

Procedure

apoc.convert.setJsonProperty(node NODE, key STRING, value ANY) - serializes the given JSON object and sets it as a property on the given NODE.

Signature

apoc.convert.setJsonProperty(node :: NODE, key :: STRING, value :: ANY)

Input parameters

Name Type Default

node

NODE

null

key

STRING

null

value

ANY

null

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
Table 1. 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;
Table 2. Results
map

{a: [4, 5, 6]}