Failed to invoke procedure `apoc.import.json`: Caused by: java.lang.NullPointerException
Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-16-2022 04:06 AM
I have a json file with some data. When I'm trying to import it, I'm getting below exception.
Failed to invoke procedure `apoc.import.json`: Caused by: java.lang.NullPointerException
08-16-2022 04:44 AM - edited 08-16-2022 04:47 AM
Can you post your export query and the exported file, or a portion if big? I don’t see that configuration parameter for apoc.export.json.data.
What does the following you posted represent?
{
"nodes": []
"rels": []
}
08-16-2022 05:09 AM
query:
08-16-2022 06:12 AM
Try exporting without specifying a format. It looks like the import assumes the default format.
08-16-2022 07:19 PM
@glilienfield Tried with default format. It's working. But what about jsonFormat:'JSON' format.
08-16-2022 09:28 PM
It seems the apoc.json.import procedure assumes a specific format, which is to have each node and relationship on separate lines. This seems to be the same format the apoc.json.export procedure uses by default ('JSON_LINES'). As such, you can export your data using apoc.json.export and import it with apoc.json.import if you use the default format during export.
The jsonFormat:'JSON' produces a map like structure. Use it if that is what you require.
These references describe it in detail
https://neo4j.com/labs/apoc/4.4/export/json/
https://neo4j.com/labs/apoc/4.4/overview/apoc.import/apoc.import.json/
08-19-2022 12:52 AM
@glilienfield but in https://neo4j.com/labs/apoc/4.2/overview/apoc.import/apoc.import.json/
clearly mentioned that The apoc.import.json
procedure can be used to import JSON files created by the apoc.export.json.*
procedures. The above data I have exported through apoc.import.json procedure.
08-19-2022 01:38 AM
Yes, the link does say that. You will notice the snippet of json they show as an example to import, which was generated by apoc.json,export.all, is in the default format. All the examples use the default format. I believe your problem is solved by exporting your database without specifying the json format, so the data is written in the default format. Afterwards, you should be eagle to import the json file and not get the null pointer exception.
All the sessions of the conference are now available online