Working with maps
In this section, we will take a look at working with maps in Cypher. Maps in Cypher represent key-value pairs. The keys must be strings and values can be any object. Maps can be defined in Cypher inline, where they are called literal maps, or they can be passed as parameters. Every node and relationship object can also be treated as a map in Cypher, so that we can access all the properties using dot (.
) notation or index ([ ]
) notation.
A map is like a JavaScript Object Notation (JSON) object. A sample JSON object looks like this:
{ "firstName": "John", "lastName": "Smith", "isAlive": true, "age": 27 }
If we represented the same map in Cypher, it would look like this:
WITH { firstName: "John", lastName: "Smith", isAlive: true, age: 27 } as map RETURN map
We can see from the code...