Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-07-2020 11:16 AM
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.
07-13-2020 08:21 AM
I have the same issue, quite weird that the output JSON isn't a valid JSON, took me a while to figure it out, I really wasn't expecting it...
01-25-2021 09:01 AM
I wonder if anyone is paying attention to these posts. A valid JSON file should be produced.
01-25-2021 09:09 AM
Hi guys,
the apoc.export.json
at this very moment exports valid Json lines:
https://jsonlines.org/
It's a format supported by various big data frameworks such as Apache Spark
Btw we merged a new feature that will be available in the next release:
That will add support for single json formats.
If you want you can test it by compiling the project from the source
All the sessions of the conference are now available online