You can do this by serializing the nested map into a json string and clicking on node. If your requirement
{address:{firstline:"a",secondline:"b"},name:"ABC"}
Then iterate over the map, if the value is not a valid type in neo4j, then convert it to json string. those. you convert
{firstline:"a",secondline:"b"}==>json string.
In cypher, it acts like a normal string. SO works. When you retrieve data from a node, de-serialize the properties for your own objects.
The downside with this approach is that you need to de-serialize each property, because we do not know if the value is a normal string or is it a json string containing a nested map.
So, my solution for this is when you convert to json string, you specify which keys are converted to json, and store this information in node using a specific key, for example: when reading json_keys=['address'] only convert these keys to json_keys array.
1)your map = {address: {firstline:"a", secondline:"b"}, name:"ABC"} 2)convert to json = {address: '{firstline:"a", secondline:"b"}', name:"ABC"} 3)note which keys are converted = {address: '{firstline:"a", secondline:"b"}', name:"ABC",json_keys=["address"]}
source share