cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Cypher Return formatted json response

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

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

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.