Java 使用spring-data-neo4j从neo4j密码查询获取JSON
如何将模板返回的结果对象转换为Json?使用spring-data-neo4j还有其他简单的方法获得Json响应吗Java 使用spring-data-neo4j从neo4j密码查询获取JSON,java,neo4j,spring-data-neo4j,Java,Neo4j,Spring Data Neo4j,如何将模板返回的结果对象转换为Json?使用spring-data-neo4j还有其他简单的方法获得Json响应吗 Neo4jTemplate template = new Neo4jTemplate(graphDatabase); Object result = template.exec(new GraphCallback<Object>() { public Object doWithGraph(GraphDatabase graph) throws E
Neo4jTemplate template = new Neo4jTemplate(graphDatabase);
Object result = template.exec(new GraphCallback<Object>() {
public Object doWithGraph(GraphDatabase graph) throws Exception {
QueryEngine engine = graph.queryEngine();
Result<Map<String, Object>> result
= engine.query("match n return n", null);
for (Map<String, Object> m : result) {
for (Map.Entry<String, Object> e : m.entrySet()) {
Node node = (Node) e.getValue();
System.out.println("===>>" + node.getId());
System.out.println("===>>" + node.getLabels());
}
}
return null;
}
});
请改用template.query
对于返回的结果,您可以将Result.convert方法与您自己的ResultConverter一起使用,例如通过使用Jackson进行映射来创建JSON