Amir
Amir

Reputation: 13

Neo4j export whole database to JSON_LINES, ARRAY_JSON, JSON or JSON_ID_AS_KEYS

I tried to use an APOC procedure from here to export the DB using the following:

CALL apoc.export.json.all("all.json",{useTypes:true})

I can successfuly export to JSONL. However, I am not able to change the JSON format to other available formats such as JSON_LINES, ARRAY_JSON, JSON or JSON_ID_AS_KEYS. According to the documentation the following should work but it does not:

CALL apoc.export.json.all("all.json",{config:{jsonFormat:'ARRAY_JSON'}})

The result of above procedure is in JSONL but not ARRAY_JSON.

I have also tried the solution here but did not succeed.

Cheers,

A

Upvotes: 1

Views: 855

Answers (2)

Amir
Amir

Reputation: 13

The solution for my question was changing the APOC.jar file with the latest release from here. I have had to update the syntax as well.

CALL apoc.export.json.all("all.json", {jsonFormat: 'ARRAY_JSON'})

You can open the plugin folder using the tree dots by the blue open button and chose Open Folder -> Plugins. Copy and paste the path showed into your file manager if it doesn't open.

In the plugin folder, you can see your APOC version on the apoc file name.

Upvotes: 0

jose_bacoy
jose_bacoy

Reputation: 12714

This is working now in neo4j versions 4.2.x with APOC version 4.2.0.2: https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/4.2.0.2/apoc-4.2.0.2-all.jar

The syntax is simpler. Notice the config is a dictionary rather than a nested dictionary. See my sample below.

OLD: CALL apoc.export.json.all("all.json",{config:{jsonFormat:'ARRAY_JSON'}})

NEW: CALL apoc.export.json.all("all.json", {jsonFormat: 'ARRAY_JSON'})
Result:
(type is array of dictionaries)

enter image description here

Upvotes: 2

Related Questions