ok, this is getting a little messy. Can you make the format of the keys simpler before creating the file?
Anyway, I came up with something:
CALL apoc.load.json("file:///SampleJsonFile.txt") YIELD value
UNWIND value.documents as document
WITH document.content as json
WITH json, json["common:IdentityContext-type"] as labelText
WITH
json,
toLower(apoc.text.regexGroups(labelText, '\w+(?=-)')[0][0]) as segment1,
toLower(apoc.text.regexGroups(labelText, '(?<=-)\w+(?=:)')[0][0]) as segment2,
toLower(apoc.text.regexGroups(labelText, '(?<=:)\w+')[0][0]) as segment3
WITH
json,
segment1+'_'+segment2 as label1,
segment3 as label2,
segment1+'_'+segment2+'_'+segment3 as label3
CALL apoc.create.node([label1, label2, label3], json) YIELD node
return node
Result:
{
"identity": 47,
"labels": [
"capital_harness",
"design",
"capital_harness_design"
],
"properties": {
"capital-harness:Design-designAbstraction": "Harness Drawing",
"common:ProductSystemContext-partNumber": "A06-23456-000",
"common:SecurityContext-govtClassification": "",
"common:IdentityContext-dataSourceURL": "UID2e4b5f-18e41820b0c-28de33b5199547c2f026595b7175a940/UID2e4b5f-18e4182b5cb-28de33b5199547c2f026595b7175a940/?objectId=",
"common:SecurityContext-ipClassification": "",
"common:IdentityContext-domain": "",
"common:SecurityContext-itar": "",
"common:GeneralBusinessContext-owningProject": "ELA-Aero Demo -3",
"common:IdentityContext-type": "capital-harness:Design",
"common:IdentityContext-dataSource": "Capital",
"common:IdentityContext-name": "A06-23456-000",
"common:IdentityContext-dataSourceUID": "UID2e4b5f-18e4182b5cb-28de33b5199547c2f026595b7175a940",
"common:GeneralBusinessContext-owningUser": "Rodney McCLean",
"common:LifecycleContext-lastModifiedDate": "1621285254051",
"capital-harness:Design-baseId": "UID2e4b5f-18e4182b5cb-28de33b5199547c2f026595b7175a940",
"capital-harness:Design-mcadid": "",
"common:IdentityContext-revision": "A",
"common:LifecycleContext-modifiedBy": "superuser",
"common:LifecycleContext-releaseDate": "1621285254051",
"capital-harness:Design-harnessGroup": "",
"capital-harness:Design-folderPath": "Harnesses",
"common:LifecycleContext-createdDate": "1536614738883",
"common:IdentityContext-description": "EXT",
"common:LifecycleContext-disposition": "Draft"
},
"elementId": "4:a78ea0f5-f0d7-41ba-947a-7b578538f53a:47"
}