Neo4j Export JSON Format


  • Neo4j 3.5.6 Community
  • nodejs driver 4.3.0
  • plugin: apoc-
  • node.js

I am able to run Call apoc.export.json.query and have it produce a .json file. However, trying to get my nodejs app to read this Neo4j-generated .json file as it's formatted is not working.

Here's what I'm trying on my server.js file:

const beerNameList =
CALL apoc.export.json.query(
"Match (b:Beer)
Return as name Limit 5", "../NodeProjects/bnl.json")

The resulting bnl.json file looks like this, no commas, no square brackets:

{"name":"Time Twister Imperial Stout"}
{"name":"Jubelale (2015)"}

However, when I try to read this bnl.json file with this Neo4j json formatting, it does not work. Here's what I'm reading with from server.js:

fs.readFile('bnl.json', 'utf8', (err, BNL) => {
if (err) {
console.log(Error reading file from disk: ${err});
} else {
const beerNameList2= JSON.parse(BNL);
beerNameList2.forEach(BN => {

If I manually format my bnl.json file like the following (with commas and square brackets), then my code works and console.logs the list of beer names:

[{"name":"Time Twister Imperial Stout"},
{"name":"Jubelale (2015)"},

It seems I need apoc.export.json.query to include [ ] starting and ending square brackets and to comma separate in between each name/curly bracket.

How do I get Neo4j apoc.export.json.query to export with this specific json formatting.

Many Thanks,