cancel
Showing results for 
Search instead for 
Did you mean: 

Cypher Return formatted json response

oelmounkad
Node

I'm new to neo4j and cypher and am having trouble with grouping queries with 'WITH' and 'Collect', so i have this graph as shown in the image below :


The normal response that i get has many repeated values , so i want a json result that's formatted like the following:

processes:[
     {
      node,
      subprocesses:[
                    {node , events: [
                                     {node}
                                    ] 
                    },
                    { //
                    }
                   ]
     },
     {
      node,
      subprocesses:[
                    {node , events: [
                                     {node}
                                    ] 
                    },
                    { //
                    }
                   ]
     }
]

Is there a way to regroup the graph like this on cypher or not ? Thank in advance!!

3 REPLIES 3

dominicvivek06
Graph Fellow

Can you please, post the query you have used so far ?

gabriel_toma
Ninja
Ninja

Although you can build the query to match your response, you will have to build the response in the required JSON format yourself.
Not sure of how many embedded levels you can have in your JSON: one or more than one?

clem
Graph Steward

I'm having a hard time following what you want but I will suggest maybe the DISTINCT function could help.