cypher选项将节点作为json对象返回?

时间:2013-01-28 17:54:21

标签: rest neo4j cypher

我正在使用Cypher ReST API。它返回1个具有两个名称值对“columns”和“data”的对象。有没有办法抛弃列并将节点作为对象而不是数组数组返回?更符合这一点:http://bl.ocks.org/4062045#miserables.json

这是我现在得到的:

curl -d @query --header "Content-Type:application/json" http://localhost:7474/db/data/cypher
{
  "columns" : [ "source", "r_type", "target" ],
  "data" : [ [ "Corn", "LIKES", "Parsley" ], [ "Corn", "LIKES", "Sunflowers" ], 
[ "Corn", "LIKES", "Pumpkin" ], [ "Corn", "LIKES", "Peas" ], [ "Corn", "LIKES", "Beans" ], 
[ "Corn", "HATES", "Tomato" ], [ null, null, null ], [ "Carrots", "LIKES", "Tomato" ], 
[ "Carrots", "LIKES", "Peas" ], [ "Carrots", "LIKES", "Onions" ], ....

查询文件:

{
  "query" : "start n  = node(*) match n -[r?]-> m return n.name? as source, type(r) as r_type, m.name? as target",
  "params" : {
  }
}

1 个答案:

答案 0 :(得分:3)

您可以编写server plugin来实现此目的。然后它将通过REST API提供。