I am, pretty sure the answer is NO but.. I am .. hopeful..
the apoc.export.json command works but the format it produces is not what I need to import into my simulation engine. I am under the impression that it only has one output format, is that correct? Or (hopefully) I missed something. :)
thanks guys sorry to bother you. thanks for helping me out on this one!
There are format options, which are set using the configuration map.
thanks man! I have to play with that option.. thanks Gary!
I have been, as you suggested, tried several options. I can send along the results but, I cant seem to get this right. I load this JSON format no problem, thanks in large part to your help..
{
"familyName":"happyFolks",
"dad": "Pete",
"mom":"Sue",
"children":[
{
"name":"Paul",
"hobbies":[
]
},
{
"name":"Pete",
"hobbies": [
{
"sport":{"type":"baseball", "wins":10, "loses":3},
"colors":[ 32, 32, 255 ]
},
{
"sport":{"type":"football", "wins":5, "loses":3},
"colors":[ 20, 32, 124 ]
}
]
}
]
}
into a nice graph
but getting that graph exported into the same JSON format is.. escaping me.. any ideas on a good way to do this. I did retry the different map types and even the query export (which I really like) but.. JSONL seems to.. rule the day..
Thoughts?
Thanks Gary and Crew!
It does not look like that procedure will generate a json object you require. A solution would be to create a custom procedure that would take the root node of your subgraph ("happyFolks" in your example) and traverse the graph to produce a Map<String, Object> as the returned result. The map would be a nested map. At each level you would have the properties of the current node, and a list of child nodes, which would also consist of maps with the same structure. You would return this map as the result and extract it in the driver. You could then use a json library to serialize it to a json string. I use Jackson2, but there are others. Converting it with Jackson2's ObjectMapper is a two liner.
ObjectMapper objectMapper = new ObjectMapper();
String mapAsString = objectMapper.writeValueAsString(map);
There is a method to add to the above that will write the string in a pretty format.
If you are not familiar, here are some references:
:).. yep.. that is what I thought, and the recursive mechanism that you gave me in the past was what I was thinking of building off of.. Yep, before I went through all this I thought I would ask to see if I had (and was hoping I had) missed something. I guess there is a downside to being through. Thanks man!
okay.. best get started. if you hear of anything, maybe give me a poke.. thanks man!