How do you import a json tree file without an identifier?


I have a json file that is already structured as a tree and I'm trying to import it into neo4j. The problem is there is no identifier within the keys since it is already in a tree.

A sample of the json file is shown below:


"saleTypeDesc":"Sales based on non-typical financing",








"postalZipCode":"L4T 0B4",
"unparsedAddress":"7215 GOREWAY DR SUITE 1D14 MISSISSAUGA ON L4T 0B4",
"unparsedAddress":"7215 GOREWAY DR SUITE 1D14",
"legalDescription":"PSCP 984 LEVEL 1 UNIT 111",
"propertyCodeDescription":"Commercial condominium",
"accessTypeCodeDescription":"Year Round Road Access"



I am able to import it into neo4j using apoc.load.json or apoc.load.jsonArray but I am not sure how to create the nodes since an identifier is not available in the tree structure.

WITH "SAMPLE.json" AS url
CALL apoc.load.jsonArray(url) YIELD value
UNWIND value.farmLand as f
UNWIND value.residentialStructures as r
UNWIND value.corporateOwner as c
UNWIND value.sales as s
UNWIND value.nonResidential as n
MERGE(farmland:FarmLand {})

so far I'm just trying to create one node. I know there should be a id property in the merge clause but don't know how to get it. Maybe there's an easy way to import json trees?

you can generate uuids for your entries. or hash the attributes with apoc.util.md5

otherwise check out apoc.graph.fromDocument which has a number of useful options there.

Thank you for the reply!

I checked out the apoc.graph.fromDocument documentation but it says every entry must have an id and a type (name of Label), configurable via the config params. The value can be a String, or Cypher Map or List of Maps.
I don't have any id's.

Can you give me an example of how to use the apoc.util.m5 procedure? And will this maintain the json's tree structure i.e. will the links be maintained?

It auto-generates IDs now if there are none.

Just try it out.