Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-13-2019 12:16 PM
Hello,
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:
{
"sales":[
{
"saleDate":"20180115",
"saleType":"09",
"saleAmount":225000,
"saleSuffix":"C",
"saleTypeDesc":"Sales based on non-typical financing",
"saleSuffixDesc":"Commercial",
"saleInstrumentNumber":"PR3269978"
}
],
"region":"15",
"farmLand":[
],
"rollNumber":"210505010713611",
"subRollNumber":"0000",
"activeProperty":"Y",
"corporateOwner":[
{
"nameSequence":1,
"occupancyCode":"O",
"consolidatedName":"WESTWOOD MALL HOLDINGS LIMITED",
"legalEntityCategoryCode":"X"
}
],
"nonResidential":{
"areaType":"C",
"heightMax":null,
"heightMin":null,
"structures":[
],
"yearBuiltMax":2014,
"yearBuiltMin":2014,
"totalUnitCount":null,
"yearBuiltLargest":2014,
"propertyTotalFloorArea":216
},
"farmLandComponent":"N",
"corporateOwnerFlag":"Y",
"countyMunicipality":"2105",
"propertyInformation":{
"landValue":117771,
"propertyCode":"475",
"actualLotSize":null,
"assessedValue":117000,
"accessTypeCode":"Y",
"actualFrontage":null,
"addressMailing":{
"streetName":"GOREWAY",
"streetNumber":"7215",
"postalZipCode":"L4T 0B4",
"streetTypeCode":"DR",
"unitIdentifier":"1D14",
"deliveryModeNum":null,
"unparsedAddress":"7215 GOREWAY DR SUITE 1D14 MISSISSAUGA ON L4T 0B4",
"deliveryModeCode":null,
"provinceStateCode":"ON",
"unitDesignatorCode":"SUITE",
"streetDirectionCode":null,
"cityPostalMunicipality":"MISSISSAUGA",
"streetNumberSuffixCode":null,
"additionalDeliveryInfo1":null,
"additionalDeliveryInfo2":null,
"deliveryInstallationAreaName":null,
"deliveryInstallationTypeCode":null,
"deliveryInstallationQualifier":null
},
"addressPhysical":{
"streetName":"GOREWAY",
"streetNumber":"7215",
"postalZipCode":null,
"streetTypeCode":"DR",
"unitIdentifier":"1D14",
"unparsedAddress":"7215 GOREWAY DR SUITE 1D14",
"upperStreetNumber":null,
"unitDesignatorCode":"SUITE",
"streetDirectionCode":null,
"streetNumberSuffixCode":null
},
"actualLotSizeUom":null,
"legalDescription":"PSCP 984 LEVEL 1 UNIT 111",
"propertyCodeDescription":"Commercial condominium",
"accessTypeCodeDescription":"Year Round Road Access"
},
"residentialStructures":[
]
}
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?
11-14-2019 02:49 PM
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.
11-15-2019 06:54 AM
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?
11-29-2019 02:14 PM
It auto-generates IDs now if there are none.
Just try it out.
All the sessions of the conference are now available online