MapsΒΆ
Neo4j has the concept of Maps. It makes it easy to
communicate with client-programs that can take json
as
input.
RETURN {name:"jan",age:56,courses:["neo4j","prob. theory",
"stochastic models","data analytics"]}
Maps can even be nested:
RETURN {name:"jan",age:56,lectures:{neo4j:3,probtheory:15,
stochasticmodels:10,dataanalytics:5}}
This map can be assigned to a variable in order to be used in Cyper or APOC :
:param data => [{name:'Michael',age: 21}]
:param teaching => [ {name:"jan",age:56,lectures:{neo4j:3,probtheory:15,stochasticmodels:10,dataanalytics:5}}]
APOC has many procedures to work with maps:
RETURN apoc.map.flatten($teaching[0])
We can remove the key lectures
from the map :
RETURN apoc.map.clean($teaching[0],["lectures"],[])
Apoc can be used to create maps. For example to create a map from a list:
RETURN apoc.map.fromLists(["person1","person2"],["Jan","Mieke"])
Last change: Oct 30, 2023