I'm currently trying to export data from an existing knowledge-base so that I can perform some concept normalization and merging of other json data. As it stands now I want to get the whole database into a json file. I do that with:
CALL apoc.export.json.all("temp/XXXX_db.json")
However, this generates an invalid json document. Each row is a valid json object, but the file itself is not and takes the following type of format:
{"type":"node", "id":"...", "labels":["..."],"properties":{...}}
{"type":"node", "id":"...", "labels":["..."],"properties":{...}}
{"type":"node", "id":"...", "labels":["..."],"properties":{...}}
{"type":"node", "id":"...", "labels":["..."],"properties":{...}}
{"id":"0","type":"relationship","label":"...","start":{"id":"...","labels":["..."]},"end":{"id":"...","labels":["..."]}}
{"id":"1","type":"relationship","label":"...","start":{"id":"...","labels":["..."]},"end":{"id":"...","labels":["..."]}}
Is there an easier way to automatically write the json out into a format like:
{"node":[{"labels":["..."],
"properties":{...}},
{...}],
"relationship": [{"id":"1",
"label":"...",
"start":{"id":"...","labels":["..."]},
"end":{"id":"...","labels":["..."]}
},
{...}]
}
Where the nodes and relationships are grouped in separate entries in the json?
I could manually do this, or use an external language to read the json line by line and then write out a new, valid, json file, but I have a hunch that someone might be able to suggest an easier way to do it by using Cypher.