I am trying to import this JSON file and automatically create nodes out of it but I am getting the following error,
Failed to invoke procedure `apoc.import.json`: Caused by: java.lang.NullPointerException
My command,
CALL apoc.import.json('https://drive.google.com/uc?id=1MVMAZbrl_nIGruoUsLOkcrw1jcgRli-U')
When locally saved inside import,
CALL apoc.import.json('business_types (1).json')
Refer this file to check indented format of the given file.
JSON Format:
{
"B2B": [
{
"q04ijnd6wjkcgg1cnyq04ijnd0kj42py": [
"mumbai",
"lucknow",
"delhi"
]
}
],
"B2C": [
{
"q04ijnd6wjkcgg1cnyq04ijnd0kj42py": [
"mumbai",
"lucknow",
"delhi"
]
}
]
}
Output Expected

@aditya_digala
couple of issues here
a. what version of Neo4j? / APOC?
b. i downloaded the file you provided and dropped it into a Neo4j 4.3.8 experience and saved the file to import/ and call apoc.load.json("test (2).json");
sucessfully read the file.
c. even through it read the file containing the json it created no nodes/relationships but that is expected. To create said nodes/rels one would typically run
call apoc.load.json("test (2).json") as value create (n:City {name: value.city});
note this is an example and no necessarily correct given your json. needless call apoc.load.json("test (2).json");
will do nothing more than read the json file.
Hi @dana_canzano,
a. I am using the latest version of Neo4J (4.4)
c. I have clearly used apoc.import.json
above hoping it'd load the nodes automatically. (but not apoc.load.json
)
Anyway, now that you know the structure of the json file and everything clearly mentioned above, do you have a solution to load the nodes the way I mentioned in my question?
@aditya_digala
The documentation at https://neo4j.com/labs/apoc/4.4/overview/apoc.import/apoc.import.json/
indicates
The apoc.import.json procedure can be used to import JSON files created by the apoc.export.json.* procedures.
Was your file created using apoc.export.json?
No it wasn't created using neo4J export json
.
Anyway, do you have any alternative to solve this problem?
@aditya.digala
neo4j export json
??? from the browser? or command line ? or ?
alternatives? apoc.load.json
Please solve this problem end to end if you know how to and let me know.
Suggesting only the commands cannot help me as I am a beginner.
@aditya_digala
solving this requires some work on your side. Reading a json file is simply reading a file which has some implied structure, no different than for example reading a CSV file, but the data within the file could be anything. And so its not as if a single command can simply read a file and instant create some model without some understanding of the data there in and its relatioships.
Further from your graphical representation of the data and nodes, are the values in each of the circles the labels for said node or simply a property of a given label. For example the nodes name depicted with 'Chennai', 'Delhi', 'Mumbai', is that 3 different labels or do all 3 nodes have the same label for example, `:City' and each has a respective property named 'name' and with values 'Chennai', 'Delhi', 'Mumbai'.
Further your initial file you are trying to injest is somewhat large. Not that Neo4j can not import it but it might be better to experiment with a smaller file, simply as a means to better understand how to import the data.
1 Like
Thanks a lot Dana <3
@aditya_digala you can look at the video here, that might give you pointers to next steps: