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...